Upgrade to Pro — share decks privately, control downloads, hide ads and more …

プログラム検証入門

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers.
Avatar for r1ru r1ru
September 14, 2024

 プログラム検証入門

Avatar for r1ru

r1ru

September 14, 2024
Tweet

More Decks by r1ru

Other Decks in Technology

Transcript

  1. Riru Oda @ri5255 過去の発表 • Symbolic model checker from scratch

    in Rust • WasmOS: Wasmを実行する自作Microkernel 低レイヤ開発とセキュリティとプログラム検証 最近の興味 • Rustの形式検証 2
  2. 構文 t := true | false | if t then

    t else t | 0 | succ t 例 • if true then (succ 0) else 0 • succ (if true then (succ 0) else 0) • If 0 then true else false • succ true 7
  3. 意味 E_IFTRUE if true then t2 else t3 -> t2

    E_IFFALSE if false t2 else t3 -> t3 E_IF t1 -> t1’ ならば if t1 then t2 else t3 -> if t1’ then t2 else t3 E_SUCC t1 -> t1’ ならば succ t1 -> succ t1’ 8 例 • if true then (succ 0) else 0 -> succ 0 • succ (if true then (succ 0) else 0) -> succ (succ 0) • If 0 then true else false • succ true • 値でなくかつ評価できない項が存在する • このような「正しくない」項を除きたい
  4. 型システム T := Nat | Bool T_TRUE true: Bool T_FALSE

    false: Bool T_IF t1: Bool かつ t2:T かつ t3:T ならば if t1 then t2 else t3: T T_SUCC t1: Nat ならば succ t1: Nat 9 例 • if true then (succ 0) else 0: Nat • succ (if true then (succ 0) else 0): Nat • If 0 then true else false • succ true • 「正しくない」項には型が付かない
  5. 発展的な話 • Double freeやDeadlock等、プログラムにとって「正しくない」状態は沢山ある • これらが行き詰まり状態になるように意味論を定義する • そのうえで型システムを作る (Linear Types,

    Session Types…) • すると型が付くプログラムにはこれらのバグが無いことが保証される 例 • free(x); free(x); • !c(v); done || !c(v); done 11
  6. 参考資料 • Benjamin C. Pierce. Types and Programming Languages (1st.

    ed.). The MIT Press, 2002. • Benjamin C. Pierce. Advanced Topics in Types and Programming Languages. The MIT Press, 2004. • 高野 祐輝. ゼロから学ぶRust. 講談社, 2022. 12
  7. 発展的な話 • モデル検査の一番の課題は状態空間爆発 • 対策としてAbstractionやPartial Order Reductionなどのテクニックがある • Symbolic Model

    Checkingなどの発展的なモデル検査アルゴリズムがある 20 https://www.youtube.com/live/96u4dBAOzao?t=9802s
  8. 参考資料 • Edmund M. Clarke, Orna Grumberg, and Doron A.

    Peled. Model checking. MIT Press, 2000. • Hillel Wayne. 実践TLA+. 翔泳社, 2021. • チェシャ猫. モデル検査器をつくる, 2024. 21
  9. 参考資料 • Adam Chlipala. Formal Reasoning About Programs. • 池渕未来.

    “プログラミングCoq”. IIJ. 2011. https://www.iijlab.net/activities/programming-coq/. 29
  10. 展望 • 実用に基づいた理論を研究したい • Rustの形式検証とOS開発に興味がある • Atmosphere: Towards Practical Verified

    Kernels in Rust • Beyond isolation: OS verification as a foundation for correct applications • 実際に形式手法を活用している企業の方にお話を聞きたい 32