diff options
| author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2026-11-10 09:13:35 +0100 |
|---|---|---|
| committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2026-11-10 09:13:35 +0100 |
| commit | 45a4b80a3d44f054a471cd417c7c2698f4770599 (patch) | |
| tree | 7785b86ed5a6999202c39616936556d8982d49f1 /proofs/rust-check | |
| parent | 0b0663e0c9dc664f35ffead3b395ffd2009fd98c (diff) | |
proofs: Lean transcriptions + flaw-finding, with a Rust referee
Gipfel.lean verifies the structural invariants (mark_duplicates keeps
hill indices stable). GipfelFind.lean hunts flaws: exact Int model for
the general fact, Float grid search for concrete IEEE witnesses, every
witness re-checked against the real code by rust-check/.
Findings: 1 fixed on master (is_visible azimuth wrap), 2 proven benign
via project_point (all witnesses NaN via 0*inf; residual near-zero
denominators documented), 3 open but cosmetic, 4 already handled by
the stitch caller. GipfelMathlib.lean.txt stays an unchecked sketch,
kept as .txt so it cannot pass for a verified artifact.
Verified from this location: lean checks both files clean, rust-check
runs against the workspace gipfel-core via path dependency.
Diffstat (limited to 'proofs/rust-check')
| -rw-r--r-- | proofs/rust-check/.gitignore | 1 | ||||
| -rw-r--r-- | proofs/rust-check/Cargo.lock | 380 | ||||
| -rw-r--r-- | proofs/rust-check/Cargo.toml | 9 | ||||
| -rw-r--r-- | proofs/rust-check/src/bin/f1.rs | 10 | ||||
| -rw-r--r-- | proofs/rust-check/src/main.rs | 111 |
5 files changed, 511 insertions, 0 deletions
diff --git a/proofs/rust-check/.gitignore b/proofs/rust-check/.gitignore new file mode 100644 index 0000000..2f7896d --- /dev/null +++ b/proofs/rust-check/.gitignore @@ -0,0 +1 @@ +target/ diff --git a/proofs/rust-check/Cargo.lock b/proofs/rust-check/Cargo.lock new file mode 100644 index 0000000..2bc7dad --- /dev/null +++ b/proofs/rust-check/Cargo.lock @@ -0,0 +1,380 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "adler2" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" + +[[package]] +name = "autocfg" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" + +[[package]] +name = "bytemuck" +version = "1.25.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95832e849adfb21180ccb6826a99da14e5d266ae5c2e668e1602cf234f153797" + +[[package]] +name = "byteorder-lite" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495" + +[[package]] +name = "cfg-if" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" + +[[package]] +name = "crc32fast" +version = "1.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b929dd2a135771f40afabd1073f85eed59c800b7c61901e5c254270497dad64" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crunchy" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" + +[[package]] +name = "dirs" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3e8aa94d75141228480295a7d0e7feb620b1a5ad9f12bc40be62411e38cce4e" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab" +dependencies = [ + "libc", + "option-ext", + "redox_users", + "windows-sys", +] + +[[package]] +name = "fax" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caf1079563223d5d59d83c85886a56e586cfd5c1a26292e971a0fa266531ac5a" + +[[package]] +name = "flate2" +version = "1.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "626d4928326b646e70f65ed36fc7cf9f206bdb68a0019ee7c6b4709da4e084c4" +dependencies = [ + "crc32fast", + "miniz_oxide", + "zlib-rs", +] + +[[package]] +name = "gipfel-core" +version = "0.5.5" +dependencies = [ + "dirs", + "image", + "kamadak-exif", + "quick-xml", + "tiff", +] + +[[package]] +name = "half" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ea2d84b969582b4b1864a92dc5d27cd2b77b622a8d79306834f1be5ba20d84b" +dependencies = [ + "cfg-if", + "crunchy", + "zerocopy", +] + +[[package]] +name = "image" +version = "0.25.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85ab80394333c02fe689eaf900ab500fbd0c2213da414687ebf995a65d5a6104" +dependencies = [ + "bytemuck", + "byteorder-lite", + "moxcms", + "num-traits", + "tiff", + "zune-core", + "zune-jpeg", +] + +[[package]] +name = "kamadak-exif" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8772c92c0f41c4a672cbdee6728253e5ae8fcc1c5eb5c6c676579565684bbf68" +dependencies = [ + "mutate_once", +] + +[[package]] +name = "libc" +version = "0.2.191" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a" + +[[package]] +name = "libredox" +version = "0.1.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61ff90caf6077a803a240f62fdbe88645a890bbca49ef8174c3cb0404362171d" +dependencies = [ + "libc", +] + +[[package]] +name = "memchr" +version = "2.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" + +[[package]] +name = "miniz_oxide" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b63fbc4a50860e98e7b2aa7804ded1db5cbc3aff9193adaff57a6931bf7c4b4c" +dependencies = [ + "adler2", + "simd-adler32", +] + +[[package]] +name = "moxcms" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb85c154ba489f01b25c0d36ae69a87e4a1c73a72631fc6c0eb6dde34a73e44b" +dependencies = [ + "num-traits", + "pxfm", +] + +[[package]] +name = "mutate_once" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13d2233c9842d08cfe13f9eac96e207ca6a2ea10b80259ebe8ad0268be27d2af" + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + +[[package]] +name = "proc-macro2" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "pxfm" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d55d956fa96f5ec02be2e13af0e20391a5aa83d6a074e3ad368959d0fab299ea" + +[[package]] +name = "quick-error" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" + +[[package]] +name = "quick-xml" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e660451e55124f798a69a5af3f49ccfbefbd41910eefd25caf2393e1f3473ec1" +dependencies = [ + "memchr", +] + +[[package]] +name = "quote" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "redox_users" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60dc65c0ff1a7ae1294b0c67b9f14baf70b644404010370171787bfac1038fc0" +dependencies = [ + "libredox", + "thiserror", +] + +[[package]] +name = "rust-check" +version = "0.1.0" +dependencies = [ + "gipfel-core", +] + +[[package]] +name = "simd-adler32" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea" + +[[package]] +name = "syn" +version = "2.0.119" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "3.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "thiserror" +version = "2.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "tiff" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b63feaf3343d35b6ca4d50483f94843803b0f51634937cc2ec519fc32232bc52" +dependencies = [ + "fax", + "flate2", + "half", + "quick-error", + "weezl", + "zune-jpeg", +] + +[[package]] +name = "unicode-ident" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" + +[[package]] +name = "weezl" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28ac98ddc8b9274cb41bb4d9d4d5c425b6020c50c46f25559911905610b4a88" + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "zerocopy" +version = "0.8.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5fe1f8f1b06191a00962174c61aa5005e0bb391a6d80d07e24d115c01a92ed8" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "863ad3ac83293fb4d740aedbfdc9240dd8d1a50c1099acd76ce80ce7c7230c7f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "zlib-rs" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b268e58e7c693d7c271f93ffc4ba3b380412554231c85bf61ca7af91042a4112" + +[[package]] +name = "zune-core" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d56377fd46368984a170bc5aac5567e52ca5da874caa60bea39fcbca78fb658b" + +[[package]] +name = "zune-jpeg" +version = "0.5.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27bc9d5b815bc103f142aa054f561d9187d191692ec7c2d1e2b4737f8dbd7296" +dependencies = [ + "zune-core", +] diff --git a/proofs/rust-check/Cargo.toml b/proofs/rust-check/Cargo.toml new file mode 100644 index 0000000..9691985 --- /dev/null +++ b/proofs/rust-check/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "rust-check" +version = "0.1.0" +edition = "2021" + +[dependencies] +gipfel-core = { path = "../../crates/gipfel-core" } + +[workspace] diff --git a/proofs/rust-check/src/bin/f1.rs b/proofs/rust-check/src/bin/f1.rs new file mode 100644 index 0000000..5259939 --- /dev/null +++ b/proofs/rust-check/src/bin/f1.rs @@ -0,0 +1,10 @@ +use gipfel_core::panorama::Panorama; +fn main() { + let mut p = Panorama::new(); + p.set_center_angle(400.0); // "bearing + full turn" input slip + println!("az=400°: hill at alph=-180° (220° off, behind) visible? {}", p.is_visible(-std::f64::consts::PI)); + println!("az=NaN: visible? {}", p.is_visible(f64::NAN)); + println!("az=inf: visible? {}", p.is_visible(f64::INFINITY)); + p.set_center_angle(f64::NAN); + println!("center=NaN: everything visible? {}", p.is_visible(0.0)); +} diff --git a/proofs/rust-check/src/main.rs b/proofs/rust-check/src/main.rs new file mode 100644 index 0000000..090d82a --- /dev/null +++ b/proofs/rust-check/src/main.rs @@ -0,0 +1,111 @@ +//! Referee for GipfelFind.lean Finding 2 / 2b: +//! grid-search the projection denominator with *Rust's own* f64 trig, +//! then push every exact-zero witness through the real generated +//! projection (ProjectionRectilinear::mac_x / mac_y) and classify the +//! result the way `Panorama::project_point` would (NaN filtered, inf NOT). + +use gipfel_core::projection::rectilinear::ProjectionRectilinear; +use gipfel_core::projection::{ProjArgs, Projection}; + +fn deg(d: f64) -> f64 { + d * std::f64::consts::PI / 180.0 +} + +/// The denominator of `_11` in the generated macros: +/// cos(pitch)·cos(elev)·cos(Δα) + sin(pitch)·sin(elev) +fn denom(p: f64, e: f64, d: f64) -> f64 { + p.cos() * e.cos() * d.cos() + p.sin() * e.sin() +} + +fn main() { audit(); + // Full-domain grid: pitch, elev in [-90, 90] step 1°, Δα in [-180, 180] step 2°. + // (No symmetry reduction: Rust is fast enough for 181·181·181 ≈ 5.9M evals.) + let mut zeros: Vec<(i32, i32, i32)> = Vec::new(); + let mut min = (f64::MAX, 0.0, 0.0, 0.0); + for i in -90..=90 { + for j in -90..=90 { + for k in (-90)..=90 { + let p = deg(i as f64); + let e = deg(j as f64); + let d = deg(k as f64 * 2.0); + let v = denom(p, e, d); + if v == 0.0 { + zeros.push((i, j, k * 2)); + } else if v.abs() < min.0 { + min = (v.abs(), i as f64, j as f64, k as f64 * 2.0); + } + } + } + } + println!("exact zeros in Rust libm: {} (smallest nonzero |denom| = {:.3e} at p={}° e={}° dα={}°)", + zeros.len(), min.0, min.1, min.2, min.3); + + // Group witnesses into the two predicted families. + let is_a = |(p, e, d): &(i32, i32, i32)| (d.abs() == 180) && (p + e).abs() == 90; + let is_b = |(p, e, d): &(i32, i32, i32)| *d == 0 && (p - e).abs() == 90; + let fam_a = zeros.iter().filter(|w| is_a(w)).count(); + let fam_b = zeros.iter().filter(|w| is_b(w)).count(); + let other = zeros.iter().filter(|w| !is_a(w) && !is_b(w)).count(); + println!("family A (|Δα|=180°, pitch+elev=±90°): {fam_a}"); + println!("family B (Δα=0°, pitch-elev=±90°): {fam_b}"); + println!("outside both families: {other}"); + for (p, e, d) in zeros.iter().filter(|w| !is_a(w) && !is_b(w)).take(10) { + println!(" other witness: pitch {p}° elev {e}° Δα {d}°"); + } + + // Push witnesses through the REAL projection, roll = 0° and roll = 1°. + let proj = ProjectionRectilinear; + for roll_deg in [0.0, 1.0] { + let (mut nan, mut inf, mut fin) = (0, 0, 0); + let mut ex_inf: Vec<String> = Vec::new(); + let mut ex_nan: Vec<String> = Vec::new(); + for (pi, ei, da) in &zeros { + let a = ProjArgs { + c_view: 0.0, + c_pitch: deg(*pi as f64), + c_roll: deg(roll_deg), + scale: 1000.0, + k0: 0.0, + k1: 0.0, + x0: 0.0, + m_view: deg(*da as f64), + m_elev: deg(*ei as f64), + }; + let x = proj.mac_x(a); + let y = proj.mac_y(a); + let desc = format!("pitch {pi}° elev {ei}° Δα {da}° roll {roll_deg}° -> x={x} y={y}"); + if x.is_nan() || y.is_nan() { + nan += 1; + if ex_nan.len() < 3 { ex_nan.push(desc); } + } else if !x.is_finite() || !y.is_finite() { + inf += 1; + if ex_inf.len() < 3 { ex_inf.push(desc); } + } else { + fin += 1; + } + } + println!("\nroll = {roll_deg}°: NaN (filtered by project_point): {nan} INF (PASSES the guard!): {inf} finite: {fin}"); + for s in ex_inf { println!(" INF {s}"); } + for s in ex_nan { println!(" NaN {s}"); } + } +} + +// Appended audit: full witness list + specific checks. +#[allow(dead_code)] +fn audit() { + let deg = |d: f64| d * std::f64::consts::PI / 180.0; + let denom = |p: f64, e: f64, d: f64| p.cos() * e.cos() * d.cos() + p.sin() * e.sin(); + let mut zs = Vec::new(); + for i in -90..=90 { for j in -90..=90 { for k in (-90)..=90 { + if denom(deg(i as f64), deg(j as f64), deg(k as f64 * 2.0)) == 0.0 { + zs.push((i, j, k * 2)); + } + }}} + println!("all {} witnesses:", zs.len()); + for (p, e, d) in &zs { println!(" pitch {p:>3}° elev {e:>3}° Δα {d:>4}°"); } + // the original Lean witnesses: + for (p, e, d) in [(6, 84, 180), (16, 74, 180), (32, 58, 180), (36, 54, 180)] { + let z = denom(deg(p as f64), deg(e as f64), deg(d as f64)) == 0.0; + println!("Lean witness ({p},{e},{d}) exact zero in Rust? {z}"); + } +} |
