buildLakePackage: add weak-minimax test

Verifies that buildLakePackage works with nix-only deps (no
lake-manifest.json).  Builds a proof of the weak minimax inequality
from Mathlib.Order.CompleteLattice.Basic using leanDeps = [ mathlib ].
This commit is contained in:
Nadja Yang
2026-03-21 17:53:43 -04:00
parent 84206e18a3
commit 9f1cb0f57c
7 changed files with 80 additions and 0 deletions
+8
View File
@@ -0,0 +1,8 @@
{
lib,
callPackage,
}:
lib.recurseIntoAttrs {
weak-minimax = callPackage ./weak-minimax/package.nix { };
}
@@ -0,0 +1,4 @@
import WeakMinimax
def main : IO Unit := do
IO.println "weak_minimax: verified (maximin <= minimax)"
@@ -0,0 +1,9 @@
import Mathlib.Order.CompleteLattice.Basic
/-- Weak minimax inequality (weak duality): maximin ≤ minimax.
For any payoff f into a complete lattice, the best worst-case guarantee
for the maximizing player never exceeds the minimax value. -/
theorem weak_minimax {ι κ α : Type*} [CompleteLattice α]
(f : ι κ α) :
i, j, f i j j, i, f i j :=
iSup_iInf_le_iInf_iSup f
@@ -0,0 +1,12 @@
import Lake
open Lake DSL
package weakMinimax
require "leanprover-community" / "mathlib" @ git "main"
@[default_target] lean_lib WeakMinimax
@[default_target]
lean_exe weakMinimax.run where
root := `Main
@@ -0,0 +1,40 @@
# Test that buildLakePackage works with nix-only deps (no lake-manifest.json).
# Builds a Lean proof of the weak minimax inequality using mathlib.
#
# Note: building the executable recompiles .c → .c.o for all transitive
# dependency modules because library packages only ship .olean/.ilean/.c
# artifacts (the default Lake library facet). Lake's trace system would
# reuse pre-built object files if present, but since Lean 4 is rarely
# used for application code, we defer shipping .o files in library
# packages to keep store footprint minimal.
{
leanPackages,
runCommand,
}:
let
inherit (leanPackages) buildLakePackage mathlib;
testPackage = buildLakePackage {
pname = "weak-minimax";
version = "0";
src = ./.;
leanDeps = [ mathlib ];
};
in
runCommand "buildLakePackage-weak-minimax"
{
nativeBuildInputs = [ testPackage ];
}
''
mkdir -p $out
# Verify the executable runs (proof was verified at build time).
weakMinimax-run | tee $out/result
grep -q "weak_minimax" $out/result
# Verify library output has compiled oleans.
test -d "${testPackage}/.lake/build/lib/lean"
''
@@ -9,6 +9,7 @@
plausible,
LeanSearchClient,
importGraph,
tests,
}:
buildLakePackage {
@@ -33,6 +34,10 @@ buildLakePackage {
importGraph
];
passthru.tests = {
inherit (tests.lake) weak-minimax;
};
meta = {
description = "Mathematical library for Lean 4";
homepage = "https://github.com/leanprover-community/mathlib4";
+2
View File
@@ -172,6 +172,8 @@ in
go = recurseIntoAttrs (callPackage ../build-support/go/tests.nix { });
lake = callPackage ../build-support/lake/test { };
pkg-config = recurseIntoAttrs (callPackage ../top-level/pkg-config/tests.nix { });
buildRustCrate = recurseIntoAttrs (callPackage ../build-support/rust/build-rust-crate/test { });