fix(gauss-bonnet): delete HyperIdeal overloads — wrong identity for hyperbolic metrics

Finding-B from doc/reviewer/external-audit-2026-05-30.md.

The Euclidean Gauss–Bonnet identity Σ(2π−Θ_v) = 2π·χ is ONLY valid for
flat/Euclidean and spherical metrics.  For hyperbolic metrics (HyperIdeal)
the correct identity is Σ(2π−Θ_v) − Area(M) = 2π·χ.  The previously
provided gauss_bonnet_sum(HyperIdealMaps) overload would silently pass the
wrong LHS to check_gauss_bonnet, which would always throw "deficit = ±Area"
for valid hyperbolic targets.

Fix:
- gauss_bonnet_sum(mesh, HyperIdealMaps)        → = delete + explanation comment
- enforce_gauss_bonnet(mesh, HyperIdealMaps&)   → = delete + explanation comment
- Header box comment rewritten with the correct hyperbolic Gauss–Bonnet
  identity and a clear "HyperIdeal: NOT SUPPORTED" section

New test in test_phase6.cpp:
- HyperIdeal_EuclideanSumDiscrepancy_DocumentsWhyCheckIsDeleted
  verifies numerically that the Euclidean sum = 0 but 2π·χ = 4π for a
  regular tetrahedron, documenting the −4π discrepancy that motivated
  the deletion
- Three compile-time static_asserts (SFINAE) confirm the overload is not
  invocable with HyperIdealMaps but remains so with Euclidean/SphericalMaps

263/263 CGAL tests pass, 0 failed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Tarik Moussa
2026-05-31 00:07:07 +02:00
parent faf96ee28c
commit 46c0b63de8
3 changed files with 142 additions and 18 deletions

View File

@@ -247,12 +247,33 @@ being instantiated with `HyperIdealMaps`. Add a comment explaining why.
compares against `2π·χ`. This requires computing the area from the HyperIdeal
metric, which is non-trivial.
### Resolution (2026-05-31)
1. **`gauss_bonnet_sum(mesh, HyperIdealMaps)` deleted** — replaced with
`= delete` overload and a multi-line comment explaining the Area-term
discrepancy. Attempting to call this is now a compile error.
2. **`enforce_gauss_bonnet(mesh, HyperIdealMaps&)` deleted** — explicit
`= delete` overload prevents the generic template from being silently
instantiated with HyperIdealMaps.
3. **Header comment block rewritten** — now has a clear box explaining
which geometries are supported (Euclidean/Spherical) and which are not
(HyperIdeal), with the correct hyperbolic GaussBonnet identity shown.
4. **One new GTest** in `test_phase6.cpp`:
- `HyperIdeal_EuclideanSumDiscrepancy_DocumentsWhyCheckIsDeleted`
verifies numerically that for a regular (Θ_v=2π) tetrahedron the
Euclidean sum = 0 while 2π·χ = 4π, i.e. the Euclidean check would
produce deficit = 4π for a valid HyperIdeal target.
5. **Three compile-time `static_assert`s** in the test file (SFINAE-based)
confirm that `gauss_bonnet_sum` is NOT invocable with HyperIdealMaps
but IS invocable with EuclideanMaps and SphericalMaps.
**Test result:** 263/263 CGAL tests pass. No regressions.
### Acceptance criteria
- [ ] Calling `check_gauss_bonnet(mesh, hyper_ideal_maps)` on a valid genus-2 mesh
with Θ_v = 2π either (a) does not compile, (b) throws with a meaningful message
distinguishing "wrong formula" from "actual violation", or (c) is removed
- [ ] A comment explains why Euclidean G-B does not apply to HyperIdeal
- [ ] 246 CGAL tests still pass
- [x] Calling `check_gauss_bonnet(mesh, hyper_ideal_maps)` → compile error
- [x] Calling `enforce_gauss_bonnet(mesh, hyper_ideal_maps)` → compile error
- [x] Comments explain why Euclidean G-B does not apply to HyperIdeal
- [x] 263 CGAL tests pass, 0 failed
---
@@ -679,7 +700,7 @@ index. Add a comment:
| ID | File | Lines | Type | Severity | Status |
|----|------|-------|------|----------|--------|
| A | `hyper_ideal_functional.hpp` | 319344 | Bug | Critical (mixed config) | ✅ Fixed 2026-05-30 |
| B | `gauss_bonnet.hpp` | 8788, 128134 | API error | Medium | 🟡 Open |
| B | `gauss_bonnet.hpp` | 8788, 128134 | API error | Medium | ✅ Fixed 2026-05-31 |
| C | `euclidean_hessian.hpp` | 2627, 5758 | Doc error | Medium | 🟡 Open |
| D | `euclidean_functional.hpp` + 2 others | 97107 | Doc error | Medium | 🟡 Open |
| E | `cp_euclidean_functional.hpp` | 338349, 373387 | Inconsistency | Medium | 🟡 Open |