two camps of program verifjcation
play

Two camps of program verifjcation Interactive Theorem Provers - PowerPoint PPT Presentation

Guido Martnez Nik Swamy ECI 2019 1 / 15 An introduction to Meta- F Two camps of program verifjcation Interactive Theorem Provers (ITPs): Coq, Agda, Lean, Idris, ... Program Verifjers: Dafny, VCC, Liquid Haskell, ... Verifjcation


  1. Guido Martínez Nik Swamy ECI 2019 1 / 15 An introduction to Meta- F ‹

  2. Two camps of program verifjcation Interactive Theorem Provers (ITPs): Coq, Agda, Lean, Idris, ... Program Verifjers: Dafny, VCC, Liquid Haskell, ... Verifjcation conditions (VCs) computed and sent to SMT solvers Simple proofs often automatic When the solver fails, no good way out Need to tweak the program (to call lemmas, etc) No automation No good way to inspect or transform the proof environment Can we retain the comfort of automation while avoiding the solver’s issues? 2 / 15 ‚ Usually for pure programs ‚ Very expressive ‚ Have traditionally relied on tactics for doing proofs

  3. Two camps of program verifjcation Interactive Theorem Provers (ITPs): Coq, Agda, Lean, Idris, ... Program Verifjers: Dafny, VCC, Liquid Haskell, ... When the solver fails, no good way out Need to tweak the program (to call lemmas, etc) No automation No good way to inspect or transform the proof environment Can we retain the comfort of automation while avoiding the solver’s issues? 2 / 15 ‚ Usually for pure programs ‚ Very expressive ‚ Have traditionally relied on tactics for doing proofs ‚ Verifjcation conditions (VCs) computed and sent to SMT solvers ‚ Simple proofs often automatic

  4. Two camps of program verifjcation Interactive Theorem Provers (ITPs): Coq, Agda, Lean, Idris, ... Program Verifjers: Dafny, VCC, Liquid Haskell, ... Need to tweak the program (to call lemmas, etc) No automation No good way to inspect or transform the proof environment Can we retain the comfort of automation while avoiding the solver’s issues? 2 / 15 ‚ Usually for pure programs ‚ Very expressive ‚ Have traditionally relied on tactics for doing proofs ‚ Verifjcation conditions (VCs) computed and sent to SMT solvers ‚ Simple proofs often automatic ‚ When the solver fails, no good way out

  5. Two camps of program verifjcation Interactive Theorem Provers (ITPs): Coq, Agda, Lean, Idris, ... Program Verifjers: Dafny, VCC, Liquid Haskell, ... Can we retain the comfort of automation while avoiding the solver’s issues? 2 / 15 ‚ Usually for pure programs ‚ Very expressive ‚ Have traditionally relied on tactics for doing proofs ‚ Verifjcation conditions (VCs) computed and sent to SMT solvers ‚ Simple proofs often automatic ‚ When the solver fails, no good way out ‚ Need to tweak the program (to call lemmas, etc) ‚ No automation ‚ No good way to inspect or transform the proof environment

  6. Two camps of program verifjcation Interactive Theorem Provers (ITPs): Coq, Agda, Lean, Idris, ... Program Verifjers: Dafny, VCC, Liquid Haskell, ... Can we retain the comfort of automation while avoiding the solver’s issues? 2 / 15 ‚ Usually for pure programs ‚ Very expressive ‚ Have traditionally relied on tactics for doing proofs ‚ Verifjcation conditions (VCs) computed and sent to SMT solvers ‚ Simple proofs often automatic ‚ When the solver fails, no good way out ‚ Need to tweak the program (to call lemmas, etc) ‚ No automation ‚ No good way to inspect or transform the proof environment

  7. As in Coq, Agda, Lean, Idris, etc Full dependent types Rich specifjcations over both pure and efgectful computations Proof automation via an SMT solver (Z3) Now with a tactics and metaprogramming engine: Meta- F Automate hard proofs Generate verifjed programs (and fragments) automatically Language extensions in F 3 / 15 F ‹ basics ‚ Functional and efgectful programming language / program verifjer ‚ A member of the ML family ‚ Extracts to OCaml or F#; a subset (Low ‹ ) can also extract to C ‚ Used for crypto implementations (e.g. EverCrypt)

  8. Proof automation via an SMT solver (Z3) Rich specifjcations over both pure and efgectful computations Now with a tactics and metaprogramming engine: Meta- F Automate hard proofs Generate verifjed programs (and fragments) automatically Language extensions in F 3 / 15 F ‹ basics ‚ Functional and efgectful programming language / program verifjer ‚ A member of the ML family ‚ Extracts to OCaml or F#; a subset (Low ‹ ) can also extract to C ‚ Used for crypto implementations (e.g. EverCrypt) ‚ Full dependent types ‚ As in Coq, Agda, Lean, Idris, etc

  9. Automate hard proofs Now with a tactics and metaprogramming engine: Meta- F Generate verifjed programs (and fragments) automatically Language extensions in F 3 / 15 F ‹ basics ‚ Functional and efgectful programming language / program verifjer ‚ A member of the ML family ‚ Extracts to OCaml or F#; a subset (Low ‹ ) can also extract to C ‚ Used for crypto implementations (e.g. EverCrypt) ‚ Full dependent types ‚ As in Coq, Agda, Lean, Idris, etc ‚ Rich specifjcations over both pure and efgectful computations ‚ Proof automation via an SMT solver (Z3)

  10. 3 / 15 F ‹ basics ‚ Functional and efgectful programming language / program verifjer ‚ A member of the ML family ‚ Extracts to OCaml or F#; a subset (Low ‹ ) can also extract to C ‚ Used for crypto implementations (e.g. EverCrypt) ‚ Full dependent types ‚ As in Coq, Agda, Lean, Idris, etc ‚ Rich specifjcations over both pure and efgectful computations ‚ Proof automation via an SMT solver (Z3) ‚ Now with a tactics and metaprogramming engine: Meta- F ‹ ‚ Automate hard proofs ‚ Generate verifjed programs (and fragments) automatically ‚ Language extensions in F ‹

  11. An easy example let incr (r : ref int) = r := !r + 1 let r = alloc 1 in incr r; let v = !r in 4 / 15 let f () : ST unit ( requires ( λ h Ñ J )) ( ensures ( λ h () h’ Ñ J )) = assert (v == 2)

  12. The easy VC (* our assertion *) p () h5)))))) 5 / 15 @ (p: st_post_h heap unit) (h: heap). ( @ (h: heap). p () h) ù ñ ( @ (r: ref int) (h2: heap). r R h ^ h2 == alloc_heap r 1 h ù ñ r P h2 ^ ( @ (a: int) (h3: heap). a == h2.[r] ^ h3 == h2 ù ñ ( @ (b: int). b == a + 1 ù ñ r P h3 ^ ( @ (h4: heap). h4 == upd h3 r b ù ñ r P h4 ^ ( @ (v: int) (h5: heap). v == h4.[r] ^ h5 == h4 ù ñ v == 2 ^ (v == 2 ù ñ

  13. The easy VC p () h5)))))) 5 / 15 @ (p: st_post_h heap unit) (h: heap). ( @ (h: heap). p () h) ù ñ ( @ (r: ref int) (h2: heap). r R h ^ h2 == alloc_heap r 1 h ù ñ r P h2 ^ ( @ (a: int) (h3: heap). a == h2.[r] ^ h3 == h2 ù ñ ( @ (b: int). b == a + 1 ù ñ r P h3 ^ ( @ (h4: heap). h4 == upd h3 r b ù ñ r P h4 ^ ( @ (v: int) (h5: heap). v == h4.[r] ^ h5 == h4 ù ñ v == 2 ^ (* our assertion *) (v == 2 ù ñ

  14. The easy VC p () h5)))))) 5 / 15 @ (p: st_post_h heap unit) (h: heap). ( @ (h: heap). p () h) ù ñ ( @ (r: ref int) (h2: heap). r R h ^ h2 == alloc_heap r 1 h ù ñ ✓ r P h2 ^ ( @ (a: int) (h3: heap). a == h2.[r] ^ h3 == h2 ù ñ ( @ (b: int). b == a + 1 ù ñ r P h3 ^ ( @ (h4: heap). h4 == upd h3 r b ù ñ r P h4 ^ ( @ (v: int) (h5: heap). v == h4.[r] ^ h5 == h4 ù ñ v == 2 ^ (* our assertion *) (v == 2 ù ñ

  15. When SMT doesn’t cut it let lemma_carry_limb_unrolled (a0 a1 a2 : nat) : Lemma (a0 % p44 + p44 ∗ ((a1 + a0 / p44) % p44) + p88 ∗ (a2 + ((a1 + a0 / p44) / p44)) == a0 + p44 ∗ a1 + p88 ∗ a2) = () 6 / 15 Note: Lemma ϕ = Pure unit ( requires J ) ( ensures ( λ () Ñ ϕ ))

  16. When SMT doesn’t cut it let lemma_carry_limb_unrolled (a0 a1 a2 : nat) : Lemma (a0 % p44 + p44 ∗ ((a1 + a0 / p44) % p44) + p88 ∗ (a2 + ((a1 + a0 / p44) / p44)) == a0 + p44 ∗ a1 + p88 ∗ a2) = pow2_plus 44 44; lemma_div_mod (a1 + a0 / p44) p44; lemma_div_mod a0 p44: distributivity_add_right p88 a2 ((a1 + a0 / p44) / p44); distributivity_add_right p44 ((a1 + a0 / p44) % p44) (p44 ∗ ((a1 + a0 / p44) / p44)); distributivity_add_right p44 a1 (a0 / p44) 6 / 15 Note: Lemma ϕ = Pure unit ( requires J ) ( ensures ( λ () Ñ ϕ ))

  17. When SMT doesn’t cut it let lemma_carry_limb_unrolled (a0 a1 a2 : nat) : Lemma (a0 % p44 + p44 ∗ ((a1 + a0 / p44) % p44) + p88 ∗ (a2 + ((a1 + a0 / p44) / p44)) == a0 + p44 ∗ a1 + p88 ∗ a2) = distributivity_add_right p88 a2 ((a1 + a0 / p44) / p44); distributivity_add_right p44 ((a1 + a0 / p44) % p44) (p44 ∗ ((a1 + a0 / p44) / p44)); distributivity_add_right p44 a1 (a0 / p44) 6 / 15 Note: Lemma ϕ = Pure unit ( requires J ) ( ensures ( λ () Ñ ϕ )) Ñ pow2_plus 44 44; Ñ lemma_div_mod (a1 + a0 / p44) p44; Ñ lemma_div_mod a0 p44:

  18. When SMT doesn’t cut it let lemma_carry_limb_unrolled (a0 a1 a2 : nat) : Lemma (a0 % p44 + p44 ∗ ((a1 + a0 / p44) % p44) + p88 ∗ (a2 + ((a1 + a0 / p44) / p44)) == a0 + p44 ∗ a1 + p88 ∗ a2) = 6 / 15 Note: Lemma ϕ = Pure unit ( requires J ) ( ensures ( λ () Ñ ϕ )) Ñ pow2_plus 44 44; Ñ lemma_div_mod (a1 + a0 / p44) p44; Ñ lemma_div_mod a0 p44: Ñ distributivity_add_right p88 a2 ((a1 + a0 / p44) / p44); Ñ distributivity_add_right p44 ((a1 + a0 / p44) % p44) (p44 ∗ ((a1 + a0 / p44) / p44)); Ñ distributivity_add_right p44 a1 (a0 / p44)

  19. When SMT doesn’t cut it let lemma_carry_limb_unrolled (a0 a1 a2 : nat) : Lemma (a0 % p44 + p44 ∗ ((a1 + a0 / p44) % p44) + p88 ∗ (a2 + ((a1 + a0 / p44) / p44)) == a0 + p44 ∗ a1 + p88 ∗ a2) = 6 / 15 Note: Lemma ϕ = Pure unit ( requires J ) ( ensures ( λ () Ñ ϕ )) Ñ pow2_plus 44 44; Ñ lemma_div_mod (a1 + a0 / p44) p44; Ñ lemma_div_mod a0 p44: Ñ distributivity_add_right p88 a2 ((a1 + a0 / p44) / p44); Ñ distributivity_add_right p44 ((a1 + a0 / p44) % p44) (p44 ∗ ((a1 + a0 / p44) / p44)); Ñ distributivity_add_right p44 a1 (a0 / p44)

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend