The fun of proof driven development




       @mzp /




                                 Reject
                 1
(   )
•   @mzp /

•

•

•
             2
Reject
    ↓            Ruby
                        Ruby

@Dominion525




                          3
Ruby




 4
Ruby



• Coq to Ruby




                 4
Ruby



• Coq to Ruby
• Git


                 4
Ruby



• Coq to Ruby
• Git
•                    Perl



                 4
•            Reject     Coq to
    Ruby



•          Reject



                    5
@mzp /




             Reject
         6
(
             )


‘‘
     Coq                          Merge Sort          -


     http://d.hatena.ne.jp/yoshihiro503/20090923/p1
          7
MessagePack
•                             @frsyuki



•
•
    (Java,C++,Ruby, Python,Perl,Haskell)
•          RPC

     OCaml
                          8
•
    •
•
    •   Base64
    •
    •
                 Coq
                       9
MessagePack for OCaml

•
• https://github.com/mzp/msgpack-ocaml
•


                    10
11
12
Coq
(*                                         *)
Infix "@@" := atat (right associativity, at level 75).

(*                                    *)
Notation "[ ]" := nil : list_scope.

(*                      (   : [1; 2; 3])         (!) *)
Notation "[ a ; .. ; b ]" := (a :: .. (b :: []) ..) : list_scope.

                               13
TDD
• TDD            =



• Coq                    =
        =            !

•
            14
•       :



•       : Twitter

    •        Twitter        Coq


                       15
•   2 3

    •   255   int -> uchar         uchar->int

•   Coq           Anarchy Proof(                )




                     16
:   Scala
    17
18
•

•

•        !

•
    19
•   !

•

•

        20
•
•   :

•       : OCaml




              21
The darkside of the Proof Driven Development



                     22
Coq < Check 5001.
Warning: Stack overflow or segmentation fault happens when
working with large
numbers in nat (observed threshold may vary from 5000 to
70000 depending on
your system limits and on the command executed).
5001 : nat



                              23
?
• nat
 •
   Inductive nat : Set :=
      O           (* 0 *)
    | S (_ : nat) (* 1    *)


               24
• MessagePack        2^n



(*   : 2^n * 2^m = 2^(n+m) *)
Lemma pow_add: forall n m,
  pow n * pow m = pow (n + m).



                25
Definition Soundness obj1 x := forall obj2,
  Serialized obj1 x ->
  Serialized obj2 x ->
  Valid obj1 ->
  Valid obj2 ->
  obj1 = obj2.


   •

                    26
CI
•                            (CI)



•
        (1GB    )

    •          VPS     orz

    •    Coq on EC2

               27
•   MessagePack for OCaml    2

•   4000
           ↓        2




                        28
• MessagePack for OCaml

•“     ”



•
                  29

証明駆動開発のたのしみ@名古屋reject会議

  • 1.
    The fun ofproof driven development @mzp / Reject 1
  • 2.
    ( ) • @mzp / • • • 2
  • 3.
    Reject ↓ Ruby Ruby @Dominion525 3
  • 4.
  • 5.
  • 6.
    Ruby • Coq toRuby • Git 4
  • 7.
    Ruby • Coq toRuby • Git • Perl 4
  • 8.
    Reject Coq to Ruby • Reject 5
  • 9.
    @mzp / Reject 6
  • 10.
    ( ) ‘‘ Coq Merge Sort - http://d.hatena.ne.jp/yoshihiro503/20090923/p1 7
  • 11.
    MessagePack • @frsyuki • • (Java,C++,Ruby, Python,Perl,Haskell) • RPC OCaml 8
  • 12.
    • • • Base64 • • Coq 9
  • 13.
    MessagePack for OCaml • •https://github.com/mzp/msgpack-ocaml • 10
  • 14.
  • 15.
  • 16.
    Coq (* *) Infix "@@" := atat (right associativity, at level 75). (* *) Notation "[ ]" := nil : list_scope. (* ( : [1; 2; 3]) (!) *) Notation "[ a ; .. ; b ]" := (a :: .. (b :: []) ..) : list_scope. 13
  • 17.
    TDD • TDD = • Coq = = ! • 14
  • 18.
    : • : Twitter • Twitter Coq 15
  • 19.
    2 3 • 255 int -> uchar uchar->int • Coq Anarchy Proof( ) 16
  • 20.
    : Scala 17
  • 21.
  • 22.
    • • • ! • 19
  • 23.
    ! • • 20
  • 24.
    • • : • : OCaml 21
  • 25.
    The darkside ofthe Proof Driven Development 22
  • 26.
    Coq < Check5001. Warning: Stack overflow or segmentation fault happens when working with large numbers in nat (observed threshold may vary from 5000 to 70000 depending on your system limits and on the command executed). 5001 : nat 23
  • 27.
    ? • nat • Inductive nat : Set := O (* 0 *) | S (_ : nat) (* 1 *) 24
  • 28.
    • MessagePack 2^n (* : 2^n * 2^m = 2^(n+m) *) Lemma pow_add: forall n m, pow n * pow m = pow (n + m). 25
  • 29.
    Definition Soundness obj1x := forall obj2, Serialized obj1 x -> Serialized obj2 x -> Valid obj1 -> Valid obj2 -> obj1 = obj2. • 26
  • 30.
    CI • (CI) • (1GB ) • VPS orz • Coq on EC2 27
  • 31.
    MessagePack for OCaml 2 • 4000 ↓ 2 28
  • 32.
    • MessagePack forOCaml •“ ” • 29