Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Coq to Rubyによる証明駆動開発@名古屋ruby会議02

6,744 views

Published on

Published in: Technology
  • Be the first to comment

Coq to Rubyによる証明駆動開発@名古屋ruby会議02

  1. 1. Coq to Ruby @mzp - CSNagoya 2011/2/26 Ruby 02 1
  2. 2. • @mzp /• SE• 2
  3. 3. Ruby• Ruby = ruby-lang.org (2004/5) 3
  4. 4. • HTML5 + Rails3.0 ” ”• #101 Redmine 4
  5. 5. Reject14:50-15:10 A realtime chat application for Developers : AsakusaSattelite 5
  6. 6. D Reject TE C JE14:50-15:10 A realtime chat application for RE Developers : AsakusaSattelite 5
  7. 7. 6
  8. 8. 7
  9. 9. ?8
  10. 10. 9
  11. 11. ?10
  12. 12. :)11
  13. 13. ‘‘ Coq Merge Sort - http://d.hatena.ne.jp/yoshihiro503/20090923/p1 12
  14. 14. 13
  15. 15. Base64• encode() decode() OK•#encode "abc" # => “YWJj”decode "YWJj" # => “abc 14
  16. 16. TDD • encode decode • : Test::Unitassert_equal "", decode(encode(""))assert_equal "foo", decode(encode("foo"))assert_equal "bar", decode(encode("bar"))assert_equal "baz", decode(encode("baz")) 15
  17. 17. NG16
  18. 18. • : RushCheck http://rushcheck.rubyforge.org/index.html$ cat test.rbAssertion.new(String) do |s| s == decode(encode(s))end.check(* 100 *)$ ruby test.rbOK, passed 100 tests. 17
  19. 19. 18
  20. 20. • Goal forall ( s : string), decode (encode s) = s.•• 19
  21. 21. •=•6 => => 8•• “OCamltter” 20
  22. 22. 21
  23. 23. ×TDD ✓ ✓PDD × ✓ 22
  24. 24. UnisonOCamltter Twitter Base64MessagePack forOcaml 23
  25. 25. 24
  26. 26. Coq•• OCaml / F#•• 25
  27. 27. Coq• Haskell/OCaml/F#Fixpoint fact (n : nat) :=match n with | O => 1 | S m => n * fact mend. 26
  28. 28. Coq• Base64Theorem soundness : forall s,decode (encode s) = s.Proof. intro s; unfold encode; unfolddecode. ....Qed. 27
  29. 29. (* OCaml *)Extraction "file.ml" fact.(* Haskell *)Extraction Language Haskell.Extraction "file.hs" fact.(* Scheme *) • ? Ruby ?Extraction Language Scheme.Extraction "file.scm" fact. 28
  30. 30. (* OCaml *)Extraction "file.ml" fact.(* Haskell *)Extraction Language Haskell.Extraction "file.hs" fact.(* Scheme • *) ? Ruby ? ? Ruby ?Extraction Language Scheme.Extraction "file.scm" fact. 28
  31. 31. 29
  32. 32. Coq 29
  33. 33. @ Coq 5 Scala 5 Python 4 C# 3 Agda 1 Android 1 30
  34. 34. &31
  35. 35. :)def mult lambda{|n|lambda{|m|match(n,[:O,lambda{[:O,[]]}], Text [:S, lambda{|p|plus[m][mult[p][m]]}])}}enddef fact lambda{|n|match(n,[:O, lambda{[:S,[[:O,[]]]]}], [:S, lambda{|m|mult[n][fact[m]]}])} 32
  36. 36. •• Coq• Coq Ruby 33
  37. 37. • (15:30 15:50)• 34
  38. 38. D• TE (15:30 15:50)• C JE RE 34
  39. 39. $ git clone git://github.com/mzp/coq-ruby.git$ cd coq-ruby#$ git diff dbc4ad4#$ make bin/coqc states/initial.coq#$ ./bin/coqc -coqlib . fact.v 35

×