|
| 1 | +# CLAUDE.md - libadic Project Context |
| 2 | + |
| 3 | +## 🎯 Project Mission |
| 4 | +Building a groundbreaking C++ library for p-adic arithmetic to validate the Reid-Li Criterion - a novel approach to the Riemann Hypothesis. This is NOT a theoretical exercise - it must be production-ready, mathematically rigorous, and absolutely correct. |
| 5 | + |
| 6 | +## ⚠️ Critical User Requirements |
| 7 | +- **NO bypasses, bandaids, or workarounds** - Everything must be absolute and correct |
| 8 | +- **Exhaustive testing and proofs** - Mathematical accuracy is paramount |
| 9 | +- **Full implementations only** - No placeholders or TODOs |
| 10 | +- **Enterprise-grade quality** - Production-ready code and documentation |
| 11 | + |
| 12 | +## 📊 Current Status |
| 13 | +- ✅ **Phase 1 Complete**: All core components fully implemented |
| 14 | +- ✅ **No placeholders**: Every function has real mathematical implementation |
| 15 | +- ✅ **Tests passing**: Basic arithmetic and special functions validated |
| 16 | +- 🔄 **Milestone test**: Reid-Li criterion validation for p=5,7,11 |
| 17 | + |
| 18 | +## 🏗️ Architecture Overview |
| 19 | + |
| 20 | +``` |
| 21 | +Application Layer (Reid-Li Calculator) |
| 22 | + ↓ |
| 23 | +High-Level API (p-adic Gamma, L-functions, Logarithm) |
| 24 | + ↓ |
| 25 | +Number Fields (Qp, Zp, Cyclotomic, Characters) |
| 26 | + ↓ |
| 27 | +Base Arithmetic (GMP Wrapper, Modular Arithmetic) |
| 28 | +``` |
| 29 | + |
| 30 | +## 📂 Project Structure |
| 31 | + |
| 32 | +``` |
| 33 | +libadic/ |
| 34 | +├── include/libadic/ # Public headers (all mathematical interfaces) |
| 35 | +├── src/ # Implementation files |
| 36 | +│ ├── base/ # Core arithmetic (GMP wrapper, modular) |
| 37 | +│ ├── fields/ # Number fields (Zp, Qp, cyclotomic) |
| 38 | +│ └── functions/ # Special functions (gamma, log, L-functions) |
| 39 | +├── tests/ # Comprehensive test suite |
| 40 | +├── examples/ # Interactive demo & validation programs |
| 41 | +├── scripts/ # Build, test, and demo scripts |
| 42 | +├── docs/ # All documentation |
| 43 | +│ └── validation/ # PROOF that libadic is unique (critical!) |
| 44 | +└── build/ # Build output (git-ignored) |
| 45 | +``` |
| 46 | + |
| 47 | +## 📁 Key Files and Their Purpose |
| 48 | + |
| 49 | +### Core Mathematical Components |
| 50 | +- **include/libadic/zp.h**: p-adic integers with precision tracking |
| 51 | +- **include/libadic/qp.h**: p-adic numbers (field operations) |
| 52 | +- **include/libadic/bernoulli.h**: Bernoulli numbers B_n and B_{n,χ} |
| 53 | +- **include/libadic/characters.h**: Dirichlet character enumeration |
| 54 | +- **include/libadic/l_functions.h**: Kubota-Leopoldt L-functions |
| 55 | +- **include/libadic/padic_gamma.h**: Morita's p-adic Gamma function |
| 56 | +- **include/libadic/padic_log.h**: p-adic logarithm |
| 57 | + |
| 58 | +### Critical Test |
| 59 | +- **tests/milestone1_test.cpp**: Reid-Li criterion validation |
| 60 | + - Must verify Φ_p^(odd/even)(χ) = Ψ_p^(odd/even)(χ) |
| 61 | + - Target: Pass for p=5,7,11 with precision O(p^60) |
| 62 | + |
| 63 | +## 🔬 Mathematical Formulas Implemented |
| 64 | + |
| 65 | +### Reid-Li Criterion |
| 66 | +For odd characters χ: |
| 67 | +``` |
| 68 | +Φ_p^(odd)(χ) = Σ_{a=1}^{p-1} χ(a) * log_p(Γ_p(a)) |
| 69 | +Ψ_p^(odd)(χ) = L'_p(0, χ) |
| 70 | +``` |
| 71 | + |
| 72 | +For even characters χ: |
| 73 | +``` |
| 74 | +Φ_p^(even)(χ) = Σ_{a=1}^{p-1} χ(a) * log_p(a/(p-1)) |
| 75 | +Ψ_p^(even)(χ) = L_p(0, χ) |
| 76 | +``` |
| 77 | + |
| 78 | +### L-function Formulas |
| 79 | +``` |
| 80 | +L_p(0, χ) = -(1 - χ(p)p^{-1}) * B_{1,χ} |
| 81 | +L_p(1-n, χ) = -(1 - χ(p)p^{n-1}) * B_{n,χ}/n |
| 82 | +``` |
| 83 | + |
| 84 | +### Key Algorithms |
| 85 | +- **Hensel Lifting**: Square roots in Zp via Newton's method |
| 86 | +- **Teichmüller Characters**: ω(a) = lim a^{p^n} |
| 87 | +- **Character Enumeration**: Using generators of (Z/nZ)* |
| 88 | +- **Bernoulli Recursion**: Σ_{k=0}^{n} C(n+1,k) B_k = 0 |
| 89 | + |
| 90 | +## 🛠️ Build and Test Instructions |
| 91 | + |
| 92 | +### Docker (Recommended) |
| 93 | +```bash |
| 94 | +docker-compose up -d |
| 95 | +docker-compose exec libadic bash |
| 96 | +cd build && cmake .. && make -j$(nproc) |
| 97 | +ctest --verbose |
| 98 | +``` |
| 99 | + |
| 100 | +### Local Build |
| 101 | +```bash |
| 102 | +# Install dependencies |
| 103 | +sudo apt-get install libgmp-dev libmpfr-dev |
| 104 | + |
| 105 | +# Build |
| 106 | +mkdir build && cd build |
| 107 | +cmake -DCMAKE_BUILD_TYPE=Release .. |
| 108 | +make -j$(nproc) |
| 109 | + |
| 110 | +# Run milestone test |
| 111 | +./milestone1_test 7 60 |
| 112 | +``` |
| 113 | + |
| 114 | +## 🧪 Testing Philosophy |
| 115 | +- Every public method has unit tests |
| 116 | +- Mathematical identities verified (Wilson's theorem, Fermat's little theorem) |
| 117 | +- Convergence conditions strictly enforced |
| 118 | +- No approximations - exact p-adic arithmetic only |
| 119 | + |
| 120 | +## 📝 Implementation Notes |
| 121 | + |
| 122 | +### Complete Implementations (No Placeholders) |
| 123 | +- ✅ BernoulliNumbers::bernoulli() - Full recursive implementation |
| 124 | +- ✅ BernoulliNumbers::generalized_bernoulli() - B_{n,χ} computation |
| 125 | +- ✅ DirichletCharacter::enumerate_primitive_characters() - Complete enumeration |
| 126 | +- ✅ LFunctions::kubota_leopoldt() - Full L_p(s,χ) implementation |
| 127 | +- ✅ LFunctions::kubota_leopoldt_derivative() - L'_p(s,χ) computation |
| 128 | + |
| 129 | +### Precision Management |
| 130 | +- All operations track precision explicitly |
| 131 | +- Automatic precision reduction in arithmetic operations |
| 132 | +- Valuation tracking for Qp field elements |
| 133 | +- Convergence checking for series (log, exp, gamma) |
| 134 | + |
| 135 | +### Performance Optimizations |
| 136 | +- Caching for Bernoulli numbers and L-values |
| 137 | +- GMP for all bigint operations |
| 138 | +- Precomputed character values |
| 139 | +- Efficient modular arithmetic |
| 140 | + |
| 141 | +## ⚠️ Critical Areas |
| 142 | + |
| 143 | +### Must Verify |
| 144 | +1. Gamma function reflection formula: Γ_p(x)·Γ_p(1-x) = ±1 |
| 145 | +2. L-function special values match literature |
| 146 | +3. Character enumeration captures ALL primitive characters |
| 147 | +4. Bernoulli numbers satisfy von Staudt-Clausen theorem |
| 148 | + |
| 149 | +### Known Challenges |
| 150 | +- p-adic logarithm convergence for p=2 (needs x ≡ 1 mod 4) |
| 151 | +- Fractional Gamma function arguments need distribution relations |
| 152 | +- Large precision computations (>100 digits) need optimization |
| 153 | + |
| 154 | +## 📚 References |
| 155 | +- **DESIGN.md**: Complete specification document (MUST READ) |
| 156 | +- **README.md**: User-facing documentation |
| 157 | +- Washington's "Introduction to Cyclotomic Fields" |
| 158 | +- Koblitz's "p-adic Numbers, p-adic Analysis, and Zeta-Functions" |
| 159 | + |
| 160 | +## 🎯 Success Criteria |
| 161 | +Phase 1 is complete when: |
| 162 | +1. milestone1_test passes for p=5,7,11 |
| 163 | +2. All Reid-Li identities hold to precision O(p^60) |
| 164 | +3. No mathematical errors or approximations |
| 165 | +4. Clean compilation with -Wall -Wextra -Wpedantic |
| 166 | + |
| 167 | +## 💡 For Future Claude Instances |
| 168 | + |
| 169 | +### Key Context |
| 170 | +- User demands **absolute correctness** - no shortcuts |
| 171 | +- This validates a potential proof of Riemann Hypothesis |
| 172 | +- Every formula must match published mathematics exactly |
| 173 | +- Test exhaustively - the mathematics must be bulletproof |
| 174 | + |
| 175 | +### Common Commands |
| 176 | +```bash |
| 177 | +# Run all tests |
| 178 | +ctest --verbose |
| 179 | + |
| 180 | +# Run milestone test |
| 181 | +./build/milestone1_test 7 60 |
| 182 | + |
| 183 | +# Check specific prime |
| 184 | +./build/milestone1_test 11 40 |
| 185 | + |
| 186 | +# Debug with assertions |
| 187 | +cmake -DCMAKE_BUILD_TYPE=Debug .. && make |
| 188 | +``` |
| 189 | + |
| 190 | +### If Tests Fail |
| 191 | +1. Check convergence conditions for p-adic functions |
| 192 | +2. Verify character primitivity testing |
| 193 | +3. Ensure Bernoulli number normalization |
| 194 | +4. Compare L-function values with literature |
| 195 | + |
| 196 | +### Development Workflow |
| 197 | +1. Always check DESIGN.md for specifications |
| 198 | +2. Run tests after EVERY change |
| 199 | +3. No commits without passing tests |
| 200 | +4. Document any deviations from design |
| 201 | + |
| 202 | +## 🚀 Next Steps |
| 203 | +- [ ] Optimize for larger primes (p > 100) |
| 204 | +- [ ] Parallelize character enumeration |
| 205 | +- [ ] Add formal verification with Lean/Coq |
| 206 | +- [ ] Implement distributed computation framework |
| 207 | +- [ ] Create Python bindings for easier experimentation |
| 208 | + |
| 209 | +--- |
| 210 | + |
| 211 | +*Remember: This library could validate a breakthrough in mathematics. Every line of code matters. No compromises on correctness.* |
0 commit comments