The Lean 4.35.0 Verification Kernel
Every LeanRust certificate is an actual Lean 4 file (target/leanrust/Prove.lean) imported on top of five compact, zero-sorry kernel modules in lean/LeanRust/. The Rust type checker is only a fast filter — the Lean kernel decides whether a certificate exists.
1. Product Security Lattice (LeanRust.Label)
Every store cell carries a Label := ⟨secrecy, integrity⟩ in the product of two two-point lattices: Secrecy (low ≤ high) and Integrity (trusted ≤ tainted). A single boolean relation a.le b authorizes flows from a into b, and a single View parameter unifies confidentiality and integrity proofs.
def le? (a b : Label) : Bool :=
(a.secrecy != .high || b.secrecy == .high) &&
(a.integrity != .tainted || b.integrity == .tainted)
inductive View where
| confidentiality -- observes public cells (secrecy == .low)
| integrity -- observes trusted cells (integrity == .trusted)
2. Total Big-Step Semantics (LeanRust.Lang & Semantics)
Commands consist of skip, assign, seq, ite, and total counted loops for_ x bound body recursing structurally on (evalExpr bound s).toNat. Because while and unbounded loop are excluded, evalCmd : Cmd → Store → Store is a total function in Lean.
def evalFor (body : Cmd) (x : Var) (remaining i : Nat) (s : Store) : Store :=
match remaining with
| 0 => s
| remaining + 1 =>
evalFor body x remaining (i + 1) (evalCmd body (update s x (Int.ofNat i)))
3. Volpano–Smith–Irvine Type System (LeanRust.Typing)
TypedCmd Γ pc c tracks the program counter label pc. Branches raise pc to pc ⊔ ℓ(guard); counted loops raise pc to pc ⊔ ℓ(bound) and require the index variable to accommodate pc ⊔ ℓ(bound); assignments require pc ⊔ ℓ(expr) ≤ Γ x.
inductive TypedCmd (Γ : Context) : Label → Cmd → Prop where
| skip : ∀ pc, TypedCmd Γ pc .skip
| assign : ∀ pc x e ℓ, TypedExpr Γ e ℓ → (pc.join ℓ).le (Γ x) → TypedCmd Γ pc (.assign x e)
| seq : ∀ pc c1 c2, TypedCmd Γ pc c1 → TypedCmd Γ pc c2 → TypedCmd Γ pc (.seq c1 c2)
| ite : ∀ pc g t f ℓ, TypedExpr Γ g ℓ → TypedCmd Γ (pc.join ℓ) t → TypedCmd Γ (pc.join ℓ) f → TypedCmd Γ pc (.ite g t f)
| for_ : ∀ pc x bound body ℓ, TypedExpr Γ bound ℓ → (pc.join ℓ).le (Γ x) → TypedCmd Γ (pc.join ℓ) body → TypedCmd Γ pc (.for_ x bound body)
4. Confinement & Noninterference Soundness (LeanRust.Soundness)
Two core lemmas close the security proof:
confinement: IfTypedCmd Γ pc cand¬ v.observes pc, then for every stores,viewEq v Γ s (evalCmd c s)— a high-context branch or secret-bounded loop can never touch an observable cell.ni_soundness: IfTypedCmd Γ pc candviewEq v Γ s1 s2, thenviewEq v Γ (evalCmd c s1) (evalCmd c s2). Instantiatingv := .confidentialityandv := .integrityyields both theorems from a single typing derivation.
Re-verify the kernel locally
Run lake build from the repository root with Lean 4.35.0 installed to re-check LeanRust.Label, Lang, Semantics, Typing, Soundness, and the reference examples Vault.lean and Count.lean.