JPYC.unAllowlist_ok
名称・種別
- 名称:
JPYC.unAllowlist_ok - 種別: theorem
- モジュール:
JpycFormalVerification.AccessControlTheorems - ソース:
JpycFormalVerification/AccessControlTheorems.lean:574-579 - 概要: 成功した unAllowlist を順方向に特徴づける補助補題。
- 仕様: 対象外
型シグネチャ
lean
∀ {s s' : JPYC.State} {ctx : JPYC.CallContext} {account : JPYC.Address}, Eq (JPYC.unAllowlist s ctx account) (Except.ok s') → And (Eq ctx.sender s.allowlister) (Eq s' (s.setAllowlisted account 0))unAllowlist s ctx account が成功したという仮定から、その成立条件(allowlister であること)と結果状態の形を取り出す前向き特徴づけ補題です。
解説
何を述べているか。 unAllowlist が Except.ok s' で成功したとき、allowlister であることが成り立ち、結果 s' がs.setAllowlisted account 0に等しいことを取り出します。証明は do ブロック先頭から req_bind_eq_ok でガードを 1 枚ずつ剝がし、最後に pure_ok で pure の成功値を取り出します。
直感。 「成功した」という結果だけから、「どの条件が満たされていたか」「状態がどう変わったか」を逆算する分解です。後続の認可・効果・不変条件の定理は、すべてこの 1 本から枝分かれします。
なぜ安全性に効くか。 これは各関数の 仕様の核 です。unAllowlist_ok を一度証明しておけば、*_auth(認可)・*_sets(効果)・*_wf / *_conserves(不変条件)が短く導けます。安全性主張を 1 か所に集約する設計です。
図解
Lean ソースコード
lean
theorem unAllowlist_ok {s s' : State} {ctx : CallContext} {account : Address}
(h : unAllowlist s ctx account = .ok s') :
ctx.sender = s.allowlister ∧ s' = s.setAllowlisted account 0 := by
unfold unAllowlist onlyAllowlister at h
obtain ⟨ha, h⟩ := req_bind_eq_ok h
exact ⟨ha, pure_ok h⟩