CoqUn2010
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

CoqUn2010

on

  • 2,804 views

 

Statistics

Views

Total Views
2,804
Views on SlideShare
1,544
Embed Views
1,260

Actions

Likes
3
Downloads
15
Comments
0

8 Embeds 1,260

http://saisa.hateblo.jp 1151
http://d.hatena.ne.jp 97
http://webcache.googleusercontent.com 4
http://cloud.feedly.com 2
https://www.google.co.jp 2
http://www.google.co.jp 2
http://static.slidesharecdn.com 1
http://cache.yahoofs.jp 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />

CoqUn2010 Presentation Transcript

  • 1. Coq GC ocaml-nagoya / 2010-08-29 Coq 1
  • 2. • • ocaml-nagoya / Proof Cafe • Coq : 11 • GC 2
  • 3. github • github • http://github.com/mzp/gc 3
  • 4. GarbageCollection 4
  • 5. GC50 5
  • 6. (?) ← 6
  • 7. 7
  • 8. GC 8
  • 9. & GC • GC 3 • GC • ” ” • ” ” • A B 9
  • 10. • A ← B D C 10
  • 11. • A ← B D C 10
  • 12. • A ← B D C 10
  • 13. • A ← B D C 10
  • 14. • • A B D C 11
  • 15. • • A B ← D C 11
  • 16. • • A B ← D C 11
  • 17. 12
  • 18. 13
  • 19. M&S ? • • • 14
  • 20. Coq 15
  • 21. Coq • Coq • OCaml Coq/Gallina OCaml ※OCaml 16 Scheme,Haskell
  • 22. 17
  • 23. Record Mem := mkMem { nodes : set A; roots : set A; frees : set A; next : A -> option A; marker : A -> mark; }. 18
  • 24. Record Mem := mkMem { nodes : set A;← roots : set A; frees : set A; next : A -> option A; marker : A -> mark; }. 18
  • 25. Record Mem := mkMem { nodes : set A;← roots : set A;← frees : set A; next : A -> option A; marker : A -> mark; }. 18
  • 26. Record Mem := mkMem { nodes : set A;← roots : set A;← frees : set A;← next : A -> option A; marker : A -> mark; }. 18
  • 27. Record Mem := mkMem { nodes : set A;← roots : set A;← frees : set A;← next : A -> option A; marker : A -> mark; “ ” }. 18
  • 28. Record Mem := mkMem { nodes : set A;← roots : set A;← frees : set A;← next : A -> option A; marker : A -> mark; “ ” }. 18
  • 29. Coq 3 • Prop Ensembles • • List ListSet • • functor FSets • (List,AVL,...) • 19
  • 30. Coq 3 • Prop Ensembles • • List ListSet • • functor FSets • (List,AVL,...) • 19
  • 31. • • • Fixpoint closure (next : A -> option A) (x : A) (xs : set A) : set A := ... 20
  • 32. & 21
  • 33. • • GC • Definition GC (m1 m2 : Mem) := exists m : Mem, MarkPhase m1 m / SweepPhase m m2. 22
  • 34. • • GC • GC Definition GC (m1 m2 : Mem) := exists m : Mem, MarkPhase m1 m / SweepPhase m m2. 22
  • 35. • • GC • GC GC Definition GC (m1 m2 : Mem) := exists m : Mem, MarkPhase m1 m / SweepPhase m m2. 22
  • 36. • • GC • GC GC Definition GC (m1 m2 : Mem) := exists m : Mem, MarkPhase m1 m / SweepPhase m m2. m1 m 22
  • 37. • • GC • GC GC Definition GC (m1 m2 : Mem) := exists m : Mem, MarkPhase m1 m / SweepPhase m m2. m1 m m m2 22
  • 38. Definition MarkPhase (m1 m2 : Mem) : Prop := roots m1 = roots m2 / nodes m1 = nodes m2 / frees m1 = frees m2 / next m1 = next m2 / Included (closuresM dec m2) (marksM Marked m2). 23
  • 39. Definition MarkPhase (m1 m2 : Mem) : Prop := roots m1 = roots m2 / nodes m1 = nodes m2 / frees m1 = frees m2 / next m1 = next m2 / Included (closuresM dec m2) (marksM Marked m2). 23
  • 40. Definition MarkPhase (m1 m2 : Mem) : Prop := roots m1 = roots m2 / nodes m1 = nodes m2 / frees m1 = frees m2 / next m1 = next m2 / Included (closuresM dec m2) (marksM Marked m2). ⊆ 23
  • 41. Definition SweepPhase (m1 m2 : Mem) : Prop := roots m1 = roots m2 / nodes m1 = nodes m2 / next m1 = next m2 / frees m2 = union dec (frees m1) (marksM Unmarked m1) / forall (n : A), In n (nodes m2) -> marker m2 n = Unmarked. 24
  • 42. Definition SweepPhase (m1 m2 : Mem) : Prop := roots m1 = roots m2 / nodes m1 = nodes m2 / next m1 = next m2 / frees m2 = union dec (frees m1) (marksM Unmarked m1) / forall (n : A), In n (nodes m2) -> marker m2 n = Unmarked. 24
  • 43. Definition SweepPhase (m1 m2 : Mem) : Prop := roots m1 = roots m2 / nodes m1 = nodes m2 / next m1 = next m2 / frees m2 = union dec (frees m1) (marksM Unmarked m1) / forall (n : A), In n (nodes m2) -> marker m2 n = Unmarked. 24
  • 44. Definition SweepPhase (m1 m2 : Mem) : Prop := roots m1 = roots m2 / nodes m1 = nodes m2 / next m1 = next m2 / frees m2 = union dec (frees m1) (marksM Unmarked m1) / forall (n : A), In n (nodes m2) -> marker m2 n = Unmarked. 24
  • 45. 25
  • 46. • GC: Definition Safety (m : Mem) : Prop := Disjoint (frees m) (closuresM dec m). ∩ =Φ • Safety • Safety GC Safety 26
  • 47. • Safety • MarksAll • MarksAll: Lemma MarkPhase_Safety : forall (m1 m2 : Mem), MarkPhase m1 m2 -> Safety m1 -> Safety m2 / MarksAll m2. 27
  • 48. • Safety • MarksAll • MarksAll: Lemma MarkPhase_Safety : forall (m1 m2 : Mem), MarkPhase m1 m2 -> ← m1 m2 Safety m1 -> Safety m2 / MarksAll m2. 27
  • 49. • Safety • MarksAll • MarksAll: Lemma MarkPhase_Safety : forall (m1 m2 : Mem), MarkPhase m1 m2 -> ← m1 m2 Safety m1 -> ← m1 Safety ... Safety m2 / MarksAll m2. 27
  • 50. • Safety • MarksAll • MarksAll: Lemma MarkPhase_Safety : forall (m1 m2 : Mem), MarkPhase m1 m2 -> ← m1 m2 Safety m1 -> ← m1 Safety ... Safety m2 / MarksAll m2. ← m2 Safety MarksAll 27
  • 51. • Safety Lemma SweepPhase_Safety : forall (m1 m2 : Mem), SweepPhase m1 m2 -> Safety m1 -> MarksAll m1 -> Safety m2. 28
  • 52. • Safety Lemma SweepPhase_Safety : forall (m1 m2 : Mem), SweepPhase m1 m2 -> ← m1 m2 Safety m1 -> MarksAll m1 -> Safety m2. 28
  • 53. • Safety Lemma SweepPhase_Safety : forall (m1 m2 : Mem), SweepPhase m1 m2 -> ← m1 m2 Safety m1 -> ← m1 Safety MarksAll m1 -> Safety m2. 28
  • 54. • Safety Lemma SweepPhase_Safety : forall (m1 m2 : Mem), SweepPhase m1 m2 -> ← m1 m2 Safety m1 -> ← m1 Safety MarksAll m1 -> ← m1 MarksAll ... Safety m2. 28
  • 55. • Safety Lemma SweepPhase_Safety : forall (m1 m2 : Mem), SweepPhase m1 m2 -> ← m1 m2 Safety m1 -> ← m1 Safety MarksAll m1 -> ← m1 MarksAll ... Safety m2. ← m2 Safety 28
  • 56. 29
  • 57. Extraction 30
  • 58. Extraction • Extraction Coq OCaml ... 30
  • 59. Extraction • Extraction Coq OCaml ... • 30
  • 60. Require Import List. Extraction “foo.ml” List.length. type nat = |O | S of nat type 'a list = | Nil | Cons of 'a * 'a list (** val length : 'a1 list -> nat **) let rec length = function | Nil -> O | Cons (a, m) -> S (length m) 31
  • 61. Require Import List. Extraction “foo.ml” List.length. type nat = |O | S of nat type 'a list = ← | Nil | Cons of 'a * 'a list OCaml ... (** val length : 'a1 list -> nat **) let rec length = function | Nil -> O | Cons (a, m) -> S (length m) 31
  • 62. • Extract Inductive List.list => "list" ["[]" "(::)"]. • • CoqBase http://sourceforge.jp/projects/ coqbase/ • yoshihiro503++ 32
  • 63. 33
  • 64. • GC • • OCaml 34
  • 65. • Burdy Gemplus Avenue ,  L. Burdy “B vs. Coq to prove a Garbage Collector” 2001 35