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/AienCap/Theorems.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 / AienCap / Theorems.lean` 81 lines · 3390 bytes Raw Blame History 1 import AienCap.Model 2 namespace AienCap 3 4 /-! ## Attenuation (AIEN.INV.CAP.ATTENUATION.V1) -/ 5 6 /-- child authority is a subset of parent authority -/ 7 theorem derive_auth_subset {g : Graph} {now pid cid : Nat} {auth : Auth} {c : Token} 8 (h : Derive g now pid cid auth c) : 9 ∃ p, g.find pid = some p ∧ Auth.Sub c.auth p.auth := by 10 obtain ⟨p, hf, _, _, hs, rfl⟩ := h 11 exact ⟨p, hf, hs⟩ 12 13 /-- child expiry is no later than parent expiry -/ 14 theorem derive_expiry_le {g : Graph} {now pid cid : Nat} {auth : Auth} {c : Token} 15 (h : Derive g now pid cid auth c) : 16 ∃ p, g.find pid = some p ∧ c.expiry ≤ p.expiry := by 17 obtain ⟨p, hf, _, _, _, rfl⟩ := h 18 exact ⟨p, hf, Nat.le_refl _⟩ 19 20 /-- child remaining delegation depth is strictly less than the parent's -/ 21 theorem derive_depth_lt {g : Graph} {now pid cid : Nat} {auth : Auth} {c : Token} 22 (h : Derive g now pid cid auth c) : 23 ∃ p, g.find pid = some p ∧ c.depth < p.depth := by 24 obtain ⟨p, hf, _, hd, _, rfl⟩ := h 25 exact ⟨p, hf, by simp only []; omega⟩ 26 27 /-- a parent with depth zero cannot delegate -/ 28 theorem depth_zero_cannot_delegate {g : Graph} {now pid cid : Nat} {auth : Auth} {c : Token} 29 {p : Token} (hf : g.find pid = some p) (h0 : p.depth = 0) : 30 ¬ Derive g now pid cid auth c := by 31 rintro ⟨q, hq, _, hd, _, _⟩ 32 rw [hf] at hq 33 cases hq 34 omega 35 36 /-- delegation from an invalid (revoked, ancestor-revoked, or expired) parent is refused -/ 37 theorem derive_parent_valid {g : Graph} {now pid cid : Nat} {auth : Auth} {c : Token} 38 (h : Derive g now pid cid auth c) : 39 ∃ p, g.find pid = some p ∧ Valid g now p := by 40 obtain ⟨p, hf, hv, _⟩ := h 41 exact ⟨p, hf, hv⟩ 42 43 /-! ## Revocation and expiry (AIEN.INV.CAP.REVOCATION_CLOSURE.V1) -/ 44 45 /-- a revoked token is rejected -/ 46 theorem revoked_invalid {g : Graph} {now : Nat} {t : Token} (h : t.id ∈ g.revoked) : 47 ¬ Valid g now t := fun hv => hv.1 h 48 49 /-- an expired token is rejected -/ 50 theorem expired_invalid {g : Graph} {now : Nat} {t : Token} (h : t.expiry < now) : 51 ¬ Valid g now t := fun hv => by have := hv.2.2; omega 52 53 /-- revoking a token rejects that token -/ 54 theorem revoke_rejects_target {g : Graph} {now : Nat} {t : Token} (a : Nat) (h : t.id = a) : 55 ¬ Valid (g.revoke a) now t := 56 revoked_invalid (by simp [Graph.revoke, h]) 57 58 private theorem desc_ancRev {g : Graph} {a : Nat} {t : Token} (h : Desc g a t) : 59 AncRev (g.revoke a) t := by 60 induction h with 61 | direct hp => exact AncRev.direct hp (by simp [Graph.revoke]) 62 | up hp hf _ ih => exact AncRev.up hp hf ih 63 64 /-- revocation invalidates every descendant, at any depth -/ 65 theorem revoke_invalidates_descendants {g : Graph} {now : Nat} {a : Nat} {t : Token} 66 (h : Desc g a t) : ¬ Valid (g.revoke a) now t := 67 fun hv => hv.2.1 (desc_ancRev h) 68 69 private theorem ancRev_mono {g : Graph} {a : Nat} {t : Token} (h : AncRev g t) : 70 AncRev (g.revoke a) t := by 71 induction h with 72 | direct hp hm => exact AncRev.direct hp (by simp [Graph.revoke, hm]) 73 | up hp hf _ ih => exact AncRev.up hp hf ih 74 75 /-- revocation never turns an invalid token into a valid one -/ 76 theorem revoke_never_validates {g : Graph} {now a : Nat} {t : Token} 77 (hv : Valid (g.revoke a) now t) : Valid g now t := by 78 obtain ⟨h1, h2, h3⟩ := hv 79 exact ⟨fun h => h1 (by simp [Graph.revoke, h]), fun h => h2 (ancRev_mono h), h3⟩ 80 81 end AienCap