chore(lean): model cache, keys, scan policy, access, release age and stats

Six Lean 4 + Mathlib modules prove or refute the audited properties and cite the Go files they model. FINDINGS.md records each verdict with its Lean theorem, Go test and fix commit. The axiom audit and the currency check live in lean4/scripts.
This commit is contained in:
2026-11-23 13:16:52 +00:00
parent 3143de3a3f
commit a7b9917696
15 changed files with 1109 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
import Gohoarder
import Lean
/-! Fails unless every theorem under `Gohoarder` depends only on `propext`, `Classical.choice` and
`Quot.sound`. Run from `lean4/`: `lake env lean scripts/Axioms.lean`. -/
open Lean Elab Command
elab "#audit_axioms" : command => do
let env ← getEnv
let allowed : List Name := [``propext, ``Classical.choice, ``Quot.sound]
let mut audited : Nat := 0
let mut bad : Array String := #[]
for (n, ci) in env.constants.map₁.toList do
if `Gohoarder |>.isPrefixOf n then
if let .thmInfo _ := ci then
audited := audited + 1
let axs ← liftCoreM (collectAxioms n)
for a in axs do
if !allowed.contains a then
bad := bad.push s!"{n} uses {a}"
if bad.isEmpty then
logInfo m!"{audited} theorems audited, axioms within {allowed}"
else
throwError "unexpected axioms:\n{"\n".intercalate bad.toList}"
#audit_axioms
+33
View File
@@ -0,0 +1,33 @@
#!/bin/sh
# Fails when a Go file cited by the Lean model changed in the range with no change under lean4/.
# Usage: lean4/scripts/check_currency.sh [base-ref] (default origin/main)
set -eu
base="${1:-origin/main}"
root="$(git rev-parse --show-toplevel)"
cd "$root"
changed="$(git diff --name-only "$base"...HEAD)"
cited="$(grep -rhoE '(pkg|cmd)/[A-Za-z0-9_./-]+\.go|Dockerfile\.frontend' lean4/Gohoarder | sort -u)"
if printf '%s\n' "$changed" | grep -q '^lean4/'; then
lean_changed=yes
else
lean_changed=no
fi
status=0
for file in $cited; do
if [ ! -f "$file" ]; then
echo "MISSING: $file is cited by the Lean model but does not exist"
status=1
continue
fi
if printf '%s\n' "$changed" | grep -qx "$file" && [ "$lean_changed" = no ]; then
echo "REVIEW: $file is cited by the Lean model and changed with no lean4/ change"
status=1
fi
done
[ "$status" -eq 0 ] && echo "currency: every cited file exists and none changed without a model change"
exit "$status"