// Independently implemented exact finite audit. No floating point or Python. // Build: g++ -std=c++20 -O2 cpp/exact_atlas.cpp -o exact_atlas // Run: ./exact_atlas results/exact_atlas.csv > results/cpp_report.json #include #include #include #include #include #include #include #include #include using Row=std::array; using Mat=std::array; long long checks=0,states=0,energy_states=0; void check(bool b){++checks;if(!b)throw std::runtime_error("exact certificate failed at check "+std::to_string(checks));} int det(Row a,Row b){return a[0]*b[1]-a[1]*b[0];} int mod(int a,int q){int b=a%q;return b<0?b+q:b;} std::vector supports(const Mat&a){ std::sets; for(const auto&r:a){int bits=0;for(int i=0;i<3;++i)if(det(r,a[i]))bits|=1< cogirth(const std::vector&s,std::arrayw){ int v=100000000,count=0; for(int mask:s){int sum=0;for(int i=0;i<3;++i)if(mask&(1< minimum(const Mat&a,std::arrayw,int q){ int low=100000000,count=0; for(int x=0;x1)csv.open(argv[1]); if(argc>1&&!csv)throw std::runtime_error("cannot open CSV output"); if(csv)csv<<"a00,a01,a10,a11,a20,a21,Q,safe,unimodular,cogirth_unit,exact_squared_distance_unit\n"; std::vectorrows;for(int x=-2;x<=2;++x)for(int y=-2;y<=2;++y)if(x||y)rows.push_back({x,y}); int candidates=0,faithful=0,uni=0,safe_count=0,unsafe_count=0,unsafe_exact=0; for(int i=0;idets={det(a[0],a[1]),det(a[0],a[2]),det(a[1],a[2])}; int g=0;bool u=true;for(int z:dets){g=std::gcd(g,std::abs(z));if(std::abs(z)>1)u=false;} if(g!=1) { continue; } ++faithful; if(u) { ++uni; } auto supp=supports(a); check(!supp.empty()); for(int q=2;q<=11;++q){ bool safe=true;for(int z:dets)if(z&&std::gcd(std::abs(z),q)!=1)safe=false; if(safe)++safe_count;else ++unsafe_count; bool alias=false; for(int x=0;xw:std::vector>{{1,1,1},{1,2,3},{3,1,2}}){ auto lam=cogirth(supp,w),answer=minimum(a,w,q); if(w==std::array{1,1,1})exact=answer.first; if(safe)check(answer.first>=c*lam.first); if(u){check(answer.first==c*lam.first);check(answer.second==(q==2?1:2)*lam.second);} } if(!safe){ bool done=false; for(int r=0;r<3&&!done;++r)for(int s=r+1;s<3&&!done;++s){ int z=det(a[r],a[s]);if(!z||std::gcd(std::abs(z),q)==1)continue; std::arrayw={1,1,1};w[r]=w[s]=4*q*q; auto lam=cogirth(supp,w),ans=minimum(a,w,q); check(ans.first