Skip to content

Commit 17b3521

Browse files
committed
code dump
1 parent eceff3e commit 17b3521

42 files changed

Lines changed: 7009 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
name: Continuous Integration
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main ]
8+
schedule:
9+
- cron: '0 0 * * 0' # Weekly validation
10+
11+
jobs:
12+
build-and-test:
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
os: [ubuntu-latest, macos-latest]
18+
compiler: [gcc, clang]
19+
build_type: [Debug, Release]
20+
precision: [10, 30, 60]
21+
22+
name: ${{ matrix.os }}-${{ matrix.compiler }}-${{ matrix.build_type }}-P${{ matrix.precision }}
23+
24+
steps:
25+
- uses: actions/checkout@v3
26+
27+
- name: Install Dependencies (Ubuntu)
28+
if: runner.os == 'Linux'
29+
run: |
30+
sudo apt-get update
31+
sudo apt-get install -y build-essential cmake libgmp-dev libmpfr-dev valgrind
32+
33+
- name: Install Dependencies (macOS)
34+
if: runner.os == 'macOS'
35+
run: |
36+
brew install cmake gmp mpfr
37+
38+
- name: Configure CMake
39+
run: |
40+
cmake -B build \
41+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
42+
-DCMAKE_C_COMPILER=${{ matrix.compiler }} \
43+
-DCMAKE_CXX_COMPILER=${{ matrix.compiler == 'gcc' && 'g++' || 'clang++' }}
44+
45+
- name: Build
46+
run: cmake --build build --config ${{ matrix.build_type }} -j$(nproc 2>/dev/null || sysctl -n hw.ncpu)
47+
48+
- name: Run Unit Tests
49+
run: |
50+
cd build
51+
ctest --output-on-failure --verbose
52+
53+
- name: Run Mathematical Validation Tests
54+
run: |
55+
cd build
56+
./test_gmp_wrapper
57+
./test_zp
58+
./test_qp
59+
./test_functions
60+
61+
- name: Run Reid-Li Criterion Tests
62+
run: |
63+
cd build
64+
./milestone1_test 5 ${{ matrix.precision }}
65+
./milestone1_test 7 ${{ matrix.precision }}
66+
./milestone1_test 11 ${{ matrix.precision }}
67+
68+
- name: Memory Leak Check (Linux only)
69+
if: runner.os == 'Linux' && matrix.build_type == 'Debug'
70+
run: |
71+
cd build
72+
valgrind --leak-check=full --error-exitcode=1 ./test_gmp_wrapper
73+
valgrind --leak-check=full --error-exitcode=1 ./test_zp
74+
valgrind --leak-check=full --error-exitcode=1 ./test_qp
75+
76+
docker-validation:
77+
runs-on: ubuntu-latest
78+
name: Docker Build and Test
79+
80+
steps:
81+
- uses: actions/checkout@v3
82+
83+
- name: Build Docker Image
84+
run: docker build -t libadic:test .
85+
86+
- name: Run Tests in Container
87+
run: |
88+
docker run --rm libadic:test bash -c "cd /libadic/build && cmake .. && make -j && ctest --verbose"
89+
90+
- name: Validate Milestone Tests in Container
91+
run: |
92+
docker run --rm libadic:test bash -c "cd /libadic/build && cmake .. && make -j && ./milestone1_test 7 60"
93+
94+
mathematical-proof-validation:
95+
runs-on: ubuntu-latest
96+
name: Mathematical Proof Verification
97+
98+
steps:
99+
- uses: actions/checkout@v3
100+
101+
- name: Setup Environment
102+
run: |
103+
sudo apt-get update
104+
sudo apt-get install -y build-essential cmake libgmp-dev libmpfr-dev
105+
106+
- name: Build with Maximum Precision
107+
run: |
108+
cmake -B build -DCMAKE_BUILD_TYPE=Release
109+
cmake --build build -j$(nproc)
110+
111+
- name: Verify Core Identities
112+
run: |
113+
cd build
114+
echo "Testing Geometric Series Identity..."
115+
./test_zp | grep -q "Geometric series: (1-p) \* (1 + p + p^2 + ...) = 1"
116+
117+
echo "Testing Fermat's Little Theorem..."
118+
./test_zp | grep -q "Fermat's Little Theorem"
119+
120+
echo "Testing Wilson's Theorem..."
121+
./test_functions | grep -q "Wilson's Theorem"
122+
123+
echo "Testing Gamma Reflection Formula..."
124+
./test_functions | grep -q "Reflection formula"
125+
126+
echo "Testing Hensel's Lemma..."
127+
./test_zp | grep -q "Hensel"
128+
129+
- name: Verify Convergence Properties
130+
run: |
131+
cd build
132+
echo "Testing p-adic logarithm convergence..."
133+
./test_functions | grep -q "Convergence"
134+
135+
echo "Testing series convergence radius..."
136+
./test_functions | grep -q "converges at minimal valuation"
137+
138+
coverage-report:
139+
runs-on: ubuntu-latest
140+
name: Test Coverage Analysis
141+
142+
steps:
143+
- uses: actions/checkout@v3
144+
145+
- name: Install Dependencies
146+
run: |
147+
sudo apt-get update
148+
sudo apt-get install -y build-essential cmake libgmp-dev libmpfr-dev gcovr
149+
150+
- name: Build with Coverage
151+
run: |
152+
cmake -B build -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="--coverage"
153+
cmake --build build -j$(nproc)
154+
155+
- name: Run Tests for Coverage
156+
run: |
157+
cd build
158+
ctest --verbose
159+
./milestone1_test 5 30
160+
./milestone1_test 7 30
161+
./milestone1_test 11 30
162+
163+
- name: Generate Coverage Report
164+
run: |
165+
gcovr --root . --html --html-details -o coverage.html
166+
gcovr --root . --print-summary

CHANGELOG.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Changelog
2+
3+
All notable changes to libadic will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
### 🚀 Added
11+
- Complete p-adic arithmetic implementation (Zp and Qp classes)
12+
- Morita's p-adic Gamma function with reflection formula validation
13+
- Convergent p-adic logarithm with series expansion
14+
- Teichmüller character computation
15+
- Hensel lifting for square roots
16+
- Docker containerization for reproducible builds
17+
- Comprehensive mathematical test framework
18+
- Reid-Li Criterion validation (milestone1_test)
19+
20+
### 🔬 Mathematical Validations
21+
- Geometric series identity: (1-p)(1+p+p²+...) = 1
22+
- Fermat's Little Theorem: a^(p-1) ≡ 1 (mod p)
23+
- Wilson's Theorem: (p-1)! ≡ -1 (mod p)
24+
- Gamma reflection formula: Γ_p(x)·Γ_p(1-x) = ±1
25+
- Hensel's Lemma for solution lifting
26+
- Logarithm convergence conditions
27+
- Chinese Remainder Theorem
28+
29+
### 🏗️ Infrastructure
30+
- CMake build system with GMP/MPFR integration
31+
- GitHub Actions CI/CD pipeline
32+
- Valgrind memory leak detection
33+
- Test coverage analysis
34+
- Multi-platform support (Linux, macOS)
35+
36+
## [1.0.0] - TBD
37+
38+
### Phase 1 Completion
39+
- Core p-adic arithmetic fully implemented
40+
- Special functions (log, Gamma) validated
41+
- Reid-Li Criterion framework established
42+
- All tests passing for p=5,7,11 at precision O(p^60)
43+
44+
### Known Limitations
45+
- L-functions implementation pending (Phase 2)
46+
- Dirichlet character enumeration incomplete
47+
- Cyclotomic field operations not yet optimized
48+
49+
## Versioning Strategy
50+
51+
- **Major (X.0.0)**: Mathematical algorithm changes, API breaking changes
52+
- **Minor (0.X.0)**: New features, performance improvements
53+
- **Patch (0.0.X)**: Bug fixes, documentation updates
54+
55+
## Future Roadmap
56+
57+
### Version 2.0.0 (Phase 2)
58+
- [ ] Complete Kubota-Leopoldt L-function implementation
59+
- [ ] Full Dirichlet character enumeration
60+
- [ ] Cyclotomic field arithmetic optimization
61+
- [ ] Distributed computation support
62+
63+
### Version 3.0.0 (Phase 3)
64+
- [ ] Global Reid-Li computation
65+
- [ ] Parallel processing with MPI
66+
- [ ] GPU acceleration for large-scale computations
67+
- [ ] Web API for remote computation
68+
69+
### Version 4.0.0 (Phase 4)
70+
- [ ] Formal verification with Coq/Lean
71+
- [ ] Automated theorem proving integration
72+
- [ ] Complete Riemann Hypothesis validation framework
73+
74+
---
75+
76+
For detailed release notes, see [GitHub Releases](https://github.com/yourusername/libadic/releases).

CMakeLists.txt

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
cmake_minimum_required(VERSION 3.14)
2+
project(libadic VERSION 1.0.0 LANGUAGES CXX)
3+
4+
# Set C++ standard
5+
set(CMAKE_CXX_STANDARD 17)
6+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
7+
set(CMAKE_CXX_EXTENSIONS OFF)
8+
9+
# Compiler flags for optimization and debugging
10+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic")
11+
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -O0 -DDEBUG")
12+
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -DNDEBUG -march=native")
13+
14+
# Find required libraries
15+
find_library(GMP_LIBRARY gmp REQUIRED)
16+
find_library(MPFR_LIBRARY mpfr REQUIRED)
17+
18+
if(NOT GMP_LIBRARY)
19+
message(FATAL_ERROR "GMP library not found. Please install libgmp-dev")
20+
endif()
21+
22+
if(NOT MPFR_LIBRARY)
23+
message(FATAL_ERROR "MPFR library not found. Please install libmpfr-dev")
24+
endif()
25+
26+
# Include directories
27+
include_directories(${CMAKE_SOURCE_DIR}/include)
28+
29+
# Source files
30+
set(LIBADIC_SOURCES
31+
src/base/gmp_wrapper.cpp
32+
src/base/modular_arith.cpp
33+
src/fields/zp.cpp
34+
src/fields/qp.cpp
35+
src/fields/cyclotomic.cpp
36+
src/functions/padic_log.cpp
37+
src/functions/padic_gamma.cpp
38+
src/functions/l_functions.cpp
39+
src/functions/characters.cpp
40+
src/functions/bernoulli.cpp
41+
)
42+
43+
# Create the library
44+
add_library(adic STATIC ${LIBADIC_SOURCES})
45+
target_link_libraries(adic ${GMP_LIBRARY} ${MPFR_LIBRARY})
46+
47+
# Enable testing
48+
enable_testing()
49+
50+
# Test executables
51+
add_executable(test_gmp_wrapper tests/test_gmp_wrapper.cpp)
52+
target_link_libraries(test_gmp_wrapper adic ${GMP_LIBRARY} ${MPFR_LIBRARY})
53+
add_test(NAME test_gmp_wrapper COMMAND test_gmp_wrapper)
54+
55+
add_executable(test_zp tests/test_zp.cpp)
56+
target_link_libraries(test_zp adic ${GMP_LIBRARY} ${MPFR_LIBRARY})
57+
add_test(NAME test_zp COMMAND test_zp)
58+
59+
add_executable(test_qp tests/test_qp.cpp)
60+
target_link_libraries(test_qp adic ${GMP_LIBRARY} ${MPFR_LIBRARY})
61+
add_test(NAME test_qp COMMAND test_qp)
62+
63+
add_executable(test_functions tests/test_functions.cpp)
64+
target_link_libraries(test_functions adic ${GMP_LIBRARY} ${MPFR_LIBRARY})
65+
add_test(NAME test_functions COMMAND test_functions)
66+
67+
# Milestone test
68+
add_executable(milestone1_test tests/milestone1_test.cpp)
69+
target_link_libraries(milestone1_test adic ${GMP_LIBRARY} ${MPFR_LIBRARY})
70+
add_test(NAME milestone1_test COMMAND milestone1_test 7 60)
71+
72+
# Mathematical validation suite
73+
add_executable(validate_mathematics validate_mathematics.cpp)
74+
target_link_libraries(validate_mathematics adic ${GMP_LIBRARY} ${MPFR_LIBRARY})
75+
add_test(NAME validate_mathematics COMMAND validate_mathematics)
76+
77+
# Interactive demo
78+
add_executable(interactive_demo interactive_demo.cpp)
79+
target_link_libraries(interactive_demo adic ${GMP_LIBRARY} ${MPFR_LIBRARY})
80+
81+
# Install rules
82+
install(TARGETS adic DESTINATION lib)
83+
install(DIRECTORY include/libadic DESTINATION include)

0 commit comments

Comments
 (0)