Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aien-architecture-mv/blob/main/bootstrap/formal-oracles/lean/MutantModels.lean # aien-architecture-mv Canonical architecture for the AIEN ecosystem: flows, boundaries, ADRs, and the map from design to implementation repositories. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aien-architecture-mv / bootstrap / formal-oracles / lean / MutantModels.lean` 51 lines · 2683 bytes Raw Blame History 1 import AienCap.Theorems 2 /-! 3 # Deliberate mutants of `Derive` (each must violate attenuation) 4 5 These are WRONG on purpose. They exist so the oracle can show it kills privilege widening. 6 Each mutant model compiles; the matching claim file must not. 7 -/ 8 namespace AienCap 9 10 /-- MUTANT 1 (scope_expansion): the containment check is removed. -/ 11 def DeriveWiden (g : Graph) (now pid cid : Nat) (auth : Auth) (c : Token) : Prop := 12 ∃ p, g.find pid = some p ∧ Valid g now p ∧ 0 < p.depth ∧ 13 c = { id := cid, parent := some pid, auth := auth, depth := p.depth - 1, expiry := p.expiry } 14 15 /-- MUTANT 2 (expiration_extension): child expiry is chosen freely, not capped by the parent. -/ 16 def DeriveLongLived (g : Graph) (now pid cid : Nat) (auth : Auth) (exp : Nat) (c : Token) : Prop := 17 ∃ p, g.find pid = some p ∧ Valid g now p ∧ 0 < p.depth ∧ Auth.Sub auth p.auth ∧ 18 c = { id := cid, parent := some pid, auth := auth, depth := p.depth - 1, expiry := exp } 19 20 /-- MUTANT 3 (delegation_depth_increase): child keeps the parent's depth (no decrement). -/ 21 def DeriveNoDecrement (g : Graph) (now pid cid : Nat) (auth : Auth) (c : Token) : Prop := 22 ∃ p, g.find pid = some p ∧ Valid g now p ∧ 0 < p.depth ∧ Auth.Sub auth p.auth ∧ 23 c = { id := cid, parent := some pid, auth := auth, depth := p.depth, expiry := p.expiry } 24 25 def mroot : Token := { id := 0, parent := none, auth := [1], depth := 1, expiry := 10 } 26 def mg : Graph := { tokens := [mroot], revoked := [] } 27 28 private theorem mroot_valid : Valid mg 5 mroot := by 29 refine ⟨by simp [mg], ?_, by simp [mroot]⟩ 30 intro h 31 cases h <;> simp_all [mroot] 32 33 /-- witness: the widening mutant accepts a child holding atom 2 that the parent lacks -/ 34 theorem widen_witness : 35 ∃ c, DeriveWiden mg 5 0 1 [1, 2] c ∧ ¬ Auth.Sub c.auth mroot.auth := 36 ⟨_, ⟨mroot, by simp [mg, Graph.find, mroot], mroot_valid, by simp [mroot], rfl⟩, 37 fun h => by have := h 2 (by simp); simp [mroot] at this⟩ 38 39 /-- witness: the long-lived mutant accepts a child expiring after its parent -/ 40 theorem long_lived_witness : 41 ∃ c, DeriveLongLived mg 5 0 1 [1] 99 c ∧ ¬ c.expiry ≤ mroot.expiry := 42 ⟨_, ⟨mroot, by simp [mg, Graph.find, mroot], mroot_valid, by simp [mroot], 43 by intro a ha; simpa [mroot] using ha, rfl⟩, by simp [mroot]⟩ 44 45 /-- witness: the no-decrement mutant accepts a child whose depth is not below the parent's -/ 46 theorem no_decrement_witness : 47 ∃ c, DeriveNoDecrement mg 5 0 1 [1] c ∧ ¬ c.depth < mroot.depth := 48 ⟨_, ⟨mroot, by simp [mg, Graph.find, mroot], mroot_valid, by simp [mroot], 49 by intro a ha; simpa [mroot] using ha, rfl⟩, by simp [mroot]⟩ 50 51 end AienCap