From a1ed0ff1e0417e0e966e291010a7810cfb1905d3 Mon Sep 17 00:00:00 2001 From: Sean Collins <173011278+SMC17@users.noreply.github.com> Date: Thu, 20 Aug 2026 17:08:49 -0400 Subject: [PATCH] fix: Zig 0.16 compile and f32-exact tests on the museum spine MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @log1p is gone; pointless discard-then-use is an error; temporary struct literals are not lvalues for method calls; ProofNode premise slices cannot be *const. Lukasiewicz/Fréchet tests used == on 0.7+0.6-1 which is not exact in f32/f64. zig build test --summary all: 388/388 (Zig 0.16.0). --- src/algebraic/categorical.zig | 3 ++- src/deductive/natded.zig | 1 - src/deductive/sequent.zig | 2 +- src/deductive/sequent_search.zig | 2 -- src/fuzzy/fuzzy.zig | 2 +- src/modal/cert.zig | 1 - src/probabilistic/prob.zig | 4 ++-- src/probabilistic/wpll.zig | 4 ++-- 8 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/algebraic/categorical.zig b/src/algebraic/categorical.zig index 1fb39d2..5d2c307 100644 --- a/src/algebraic/categorical.zig +++ b/src/algebraic/categorical.zig @@ -172,5 +172,6 @@ test "topos witness gate" { .has_exponentials = true, }; try std.testing.expect(w.isElementaryTopos()); - try std.testing.expect(!ToposWitness{}.isElementaryTopos()); + const empty = ToposWitness{}; + try std.testing.expect(!empty.isElementaryTopos()); } diff --git a/src/deductive/natded.zig b/src/deductive/natded.zig index c80ccbd..9784bde 100644 --- a/src/deductive/natded.zig +++ b/src/deductive/natded.zig @@ -283,7 +283,6 @@ test "natded modus ponens" { const a1 = try pr.assume(imp); const a2 = try pr.assume(p); const q_line = try pr.impliesElim(a1, a2); - _ = q_line; // Discharge p: derive (P→Q) → ((P→Q) wait — discharge innermost first // Innermost is P, last formula Q → get P→Q (identity-ish under outer) // Actually last is Q, discharge P → (P → Q) under outer (P→Q) assumption. diff --git a/src/deductive/sequent.zig b/src/deductive/sequent.zig index 944b1a4..0ba84dc 100644 --- a/src/deductive/sequent.zig +++ b/src/deductive/sequent.zig @@ -229,7 +229,7 @@ test "sequent implies-right shape" { const node = ProofNode{ .sequent = conc, .rule = .implies_r, - .premises = &[_]*const ProofNode{&prem}, + .premises = &[_]*ProofNode{&prem}, }; try std.testing.expect(check(&node)); } diff --git a/src/deductive/sequent_search.zig b/src/deductive/sequent_search.zig index 4cce77d..ebf2545 100644 --- a/src/deductive/sequent_search.zig +++ b/src/deductive/sequent_search.zig @@ -21,7 +21,6 @@ pub const SearchResult = enum { proved, failed, depth_exceeded }; /// signed atoms (positive = right-side atom or left-side negation, etc.). /// For the spine we reduce formulas to NNF-ish signed literals via a simple /// recursive inversion. - pub const Signed = struct { atom: []const u8, /// true = positive occurrence on the side it sits @@ -56,7 +55,6 @@ pub fn search( } fn searchDepth(allocator: std.mem.Allocator, goal: sequent.Sequent, depth: u32) !SearchResult { - _ = allocator; if (goal.isInitial()) return .proved; if (depth == 0) return .depth_exceeded; diff --git a/src/fuzzy/fuzzy.zig b/src/fuzzy/fuzzy.zig index b54d110..d838d6b 100644 --- a/src/fuzzy/fuzzy.zig +++ b/src/fuzzy/fuzzy.zig @@ -128,7 +128,7 @@ pub fn kleeneOr(a: Kleene, b: Kleene) Kleene { } test "lukasiewicz t-norm bounds" { - try std.testing.expect(tnorm(.lukasiewicz, 0.7, 0.6) == @as(Degree, 0.3)); + try std.testing.expectApproxEqAbs(@as(Degree, 0.3), tnorm(.lukasiewicz, 0.7, 0.6), 1e-6); try std.testing.expect(tnorm(.lukasiewicz, 0.2, 0.3) == @as(Degree, 0)); try std.testing.expect(implies(.lukasiewicz, 0.3, 0.8) == @as(Degree, 1)); } diff --git a/src/modal/cert.zig b/src/modal/cert.zig index 64f372c..2eaa6ac 100644 --- a/src/modal/cert.zig +++ b/src/modal/cert.zig @@ -80,7 +80,6 @@ fn fingerprint(phi: *const normal.Formula) u64 { } fn forces(n: u32, rel: u32, val: u32, w: u32, phi: *const normal.Formula, n_atoms: u32) bool { - _ = n_atoms; return switch (phi.*) { .atom => |a| (val & (@as(u32, 1) << @intCast(a * n + w))) != 0, .not => |x| !forces(n, rel, val, w, x, n_atoms), diff --git a/src/probabilistic/prob.zig b/src/probabilistic/prob.zig index 04a8584..ad9f2e5 100644 --- a/src/probabilistic/prob.zig +++ b/src/probabilistic/prob.zig @@ -85,8 +85,8 @@ test "independence product" { test "frechet and bounds" { const iv = frechetAnd(0.7, 0.6); - try std.testing.expect(iv.lo == 0.3); - try std.testing.expect(iv.hi == 0.6); + try std.testing.expectApproxEqAbs(0.3, iv.lo, 1e-12); + try std.testing.expectApproxEqAbs(0.6, iv.hi, 1e-12); } test "negation complement" { diff --git a/src/probabilistic/wpll.zig b/src/probabilistic/wpll.zig index 890a0cc..5ec8273 100644 --- a/src/probabilistic/wpll.zig +++ b/src/probabilistic/wpll.zig @@ -13,8 +13,8 @@ const markov = @import("markov.zig"); /// Softplus-stable log(σ(z)) helpers. fn logSigmoid(z: f64) f64 { - if (z >= 0) return -@log1p(@exp(-z)); - return z - @log1p(@exp(z)); + if (z >= 0) return -std.math.log1p(@exp(-z)); + return z - std.math.log1p(@exp(z)); } /// Weight difference for atom j: score(x[j]=1) - score(x[j]=0) with others fixed.