SlideShare una empresa de Scribd logo
1 de 35
Descargar para leer sin conexión
in $*CcBg

      $^93 $b$(      (twitter ID: @MoCo7)


                  August 29, 2010



in $*CBgc                                       1/24
(M2)
: shift/reset ?d?J0Q0w2q
        : OCaml!$ Coq!$7wO@!$ ect.




in $*CBgc                            2/24
in $*CBgc   3/24
: ProofGeneral




   in $*CBgc     4/24
: ProofGeneral




   in $*CBgc     4/24
: ProofGeneral




OCaml Meeting $N
  talker $N 1 ?M




          in $*CBgc   4/24
: ProofGeneral




OCaml Meeting $N
  talker $N 1 ?M                  ⇑
                      <TI.$NK3




          in $*CBgc                   4/24
D1 1 ?M


M2 4 ?M

M1 2 ?M

B4 1 ?M


     in $*CBgc   5/24
Coq %<_

      2008 G/A04|3+:E
      Coq $rJY6/$7$h$&                 ! $H&%<_G7$?
          :
          1   install!$4?t!$Bg0hE?t!$
                        X        JQ*                  Specification $NDj5A
          2

          3

          4   implication 0J30$NO@M}1i;!$Ey<0$N>ZL@
                                       ;
          5

          6

          7               (TAPL 8 !$
                                  >O   soundness)

      http://pllab.is.ocha.ac.jp/lab.html


              in $*CBgc                                                     6/24
= BjL?
        %`i0mW            = L@>Z



in $*CBgc                          7/24
/)◦∀◦( yay! /)◦∀◦(
                       = BjL?
        %`i0mW                  = L@>Z
                 (◦∀◦)/ yay! (◦∀◦)/


in $*CBgc                                7/24
Coq 3Z$7$=$&




      in $*CBgc   7/24
Coq 3Z$7$=$&


      : CPDT
M2 $O8&5f$K       Coq $r;H$($F$J   ... ! (;$?$
                                            H    !)




      in $*CBgc                                   7/24
Coq 3Z$7h               Coq

       ICFP2009 $N B. C. Pierce $N>7BT9V1i
       “Lambda, the Ultimate TA: Using a Proof Assistant
       to Teach Programming Language Foundations”
            from
               Theory of PL for PL geeks
            to
               Software Foundation to the masses
       http://www.cis.upenn.edu/~bcpierce/sf



            in $*CBgc                                  9/24
: @h@8C#$,9%$-J3Hr$d$k
                    ...
           functional derivation $N<jK!$G?'!9$J
      %;^s%F%/%9$N%$s%?%Wj?$rF3$/
             #




in $*CBgc                                         10/24
{ 0z$-;→;MB'1i$                     } %$s?Wjr          ...

                  reduction semantics =q$/
                                      $G
                  CPS 49
                       JQ

factorial 4X?t$d               fibonacci 4X?t$r   ...
                  CPS 49
                      JQ




                  in $*CBgc                                  11/24
factorial 4X?t        (CPS)



    let rec fac n =
      if n <= 0 then 1
      else n * fac ( n - 1 )
    let rec fac_cps n k =
      if n <= 0 then k 1
      else
        fac_cps ( n - 1 ) ( fun x - > k ( n * x ) )
    let main n = fac_cps n ( fun x - > x )




          in $*CBgc                                   12/24
factorial 4X?t        (Hs4X?t2=   )




    type cont = C0 | C1 of int * cont
    let rec apply k x = match k with
      | C0 - > x
      | C1 (n , k ) - > apply k ( n * x )
    let rec fac_defunc n k =
      if n <= 0 then apply k 1
      else fac_defunc ( n - 1 ) ( C1 (n , k ) )
    let main n = fac_defunc n C0




          in $*CBgc                               13/24
y
            (?)



                  ~
                  Coq $G!#




in $*CBgc                    14/24
!!




in $*CBgc        15/24
!!




in $*CBgc        15/24
CPS JQ49$N@5Ev-                  (factorial)


  Theorem
    ∀n ∈ N,                   f acds n = f accps n id




                  in $*CBgc                             16/24
CPS JQ49$N@5Ev-                     (factorial)


  Theorem
    ∀n ∈ N,                      f acds n = f accps n id

  Lemma
    ∀n ∈ N, k ∈ N → N,
                k (f acds n) = f accps n k
  >ZL@      : n $K4X$9$k5"G<K!



                   in $*CBgc                               16/24
CPS JQ49$N@5Ev-                                 (factorial)


  Theorem
    ∀n ∈ N,                                 f acds n = f accps n id

  Lemma
    ∀n ∈ N, k ∈ N → N,
                k (f acds n) = f accps n k
  >ZL@         : n $K4X$9$k5"G<K!
  >e$NDjM}$O                      k = id $K$9$l$P<($,$k

                      in $*CBgc                                       16/24
(factorial)

Theorem
  ∀n ∈ N,           f accps n id = f acdef unc n C0




        in $*CBgc                                     17/24
(factorial)

Theorem
  ∀n ∈ N,                   f accps n id = f acdef unc n C0

Lemma
  ∀n ∈ N, k ∈ N → N, c ∈ cont,
(∀a ∈ N, k a = apply c a) → f accps n k = f acdef unc n c
>ZL@   : n $K4X$9$k5"G<K!



              in $*CBgc                                       17/24
(factorial)

Theorem
  ∀n ∈ N,                             f accps n id = f acdef unc n C0

Lemma
  ∀n ∈ N, k ∈ N → N, c ∈ cont,
(∀a ∈ N, k a = apply c a) → f accps n k = f acdef unc n c
>ZL@           : n $K4X$9$k5"G<K!
>e$NDjM}$O                        k = id!$ c = C0   $K
$9$l$P<($;$k

                      in $*CBgc                                         17/24
CPS JQ49               & Hs4X?t2=$N@5Ev-   (fibonacci)


     let rec fib n =
       if n <= 1 then 1
       else fib ( n - 1 ) + fib ( n - 2 )

             : $[“  factorial $HF1$83J9%
           : well founded induction $G4hD%$k




           in $*CBgc                                    18/24
CPS JQ49                 & Hs4X?t2=$N@5Ev-             (fibonacci)


     let rec fib n =
       if n <= 1 then 1
       else fib ( n - 1 ) + fib ( n - 2 )

                 : $[“ factorial $HF1$83J9%
         : well founded induction $G4hD%$k
  ??                         apply 4X?t$HAj8_:F5”$N7A$K$Jj
     Coq $G>e<j$/Dj5A=PMh$J$                ... (>ZL@$bH~$7$/$J   )




             in $*CBgc                                                18/24
fibonacci (CPS, OCaml)




   let rec fib_cps n k =
     if n < 2 then k 1
     else
       fib_cps ( n - 1 ) ( fun x - >
       fib_cps ( n - 2 ) ( fun y - > k ( x + y ) ) )




        in $*CBgc                                      19/24
fibonacci (defunctionalized, OCaml)

   type cont =
     | C0
     | C1 of int * cont_t
     | C2 of int * cont_t
   let rec apply k x = match k with
     | C0 - > x
     | C1 (n , k ) - >
         fib_defunc ( n - 2 ) ( C2 (x , k ) )
     | C2 ( n1 , k ) - > apply k ( n1 + x )
   and fib_defunc n k =
     if n < 2 then apply k 1
     else fib_defunc ( n - 1 ) ( C1 (n , k ) )

        in $*CBgc                                20/24
fibonacci (Coq)
  Fixpoint app ( k : cont_fib ) ( x : nat ) ( count : nat )
    { struct count } : option nat : =
    match count with
       | O = > None
       | S count ’ = >
           match k with
              | C0_fib = > Some x
              | C1_fib n k = >
                  fib_defunc ( minus n 1 ) ( C2_fib x k ) count ’
              | C2_fib n1 k = > app k ( plus n1 x ) count ’
           end
    end
  with fib_defunc ( n : nat ) ( k : cont_fib ) ( count : nat )
    { struct count } : option nat : =
    match count with
       | O = > None
       | S count ’ = >
           match n with
              | O | S O = > app k 1 count ’
              | S m = > fib_defunc m ( C1_fib m k ) count ’
           end
    end .


          in $*CBgc                                                 21/24
D1 $N@hGZ : Coqer
···
      M1 $N8eGZ : Coqer / Agdar
· · · functional derivation $N>ZL@ (:#$O   Agda 6/Cf
                                                 JY    )




          in $*CBgc                                        22/24
: shift/reset $ND>@“<BAu

Caml Light $K shift/reset F3F~
functional derivation $NK!$rMxM$7$F!$
                         <j       Q
definitional interpreter =⇒ ZINC $N>ZL@
                       Coq $r$?$
                               ;H           ... $b
                                                 +   ?
             Coq $r$?$
                    ;H              ... $b
                                         + ??




in $*CBgc                                                23/24
u u
              h
            
             ¤ h
            ¤   h




in $*CBgc           24/24

Más contenido relacionado

La actualidad más candente

C++ Programming - 14th Study
C++ Programming - 14th StudyC++ Programming - 14th Study
C++ Programming - 14th StudyChris Ohk
 
Ee 3122 numerical methods and statistics sessional credit
Ee 3122 numerical methods and statistics sessional  creditEe 3122 numerical methods and statistics sessional  credit
Ee 3122 numerical methods and statistics sessional creditRaihan Bin-Mofidul
 
PVS-Studio team experience: checking various open source projects, or mistake...
PVS-Studio team experience: checking various open source projects, or mistake...PVS-Studio team experience: checking various open source projects, or mistake...
PVS-Studio team experience: checking various open source projects, or mistake...Andrey Karpov
 
JavaSE7 Launch Event: Java7xGroovy
JavaSE7 Launch Event: Java7xGroovyJavaSE7 Launch Event: Java7xGroovy
JavaSE7 Launch Event: Java7xGroovyYasuharu Nakano
 
JavaScript - Agora nervoso
JavaScript - Agora nervosoJavaScript - Agora nervoso
JavaScript - Agora nervosoLuis Vendrame
 
Computer graphics programs in c++
Computer graphics programs in c++Computer graphics programs in c++
Computer graphics programs in c++Ankit Kumar
 

La actualidad más candente (19)

Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
 
Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
 
C++ Programming - 14th Study
C++ Programming - 14th StudyC++ Programming - 14th Study
C++ Programming - 14th Study
 
Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
 
Ee 3122 numerical methods and statistics sessional credit
Ee 3122 numerical methods and statistics sessional  creditEe 3122 numerical methods and statistics sessional  credit
Ee 3122 numerical methods and statistics sessional credit
 
C++ file
C++ fileC++ file
C++ file
 
New presentation oop
New presentation oopNew presentation oop
New presentation oop
 
C++ TUTORIAL 8
C++ TUTORIAL 8C++ TUTORIAL 8
C++ TUTORIAL 8
 
Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
 
Rcpp11 genentech
Rcpp11 genentechRcpp11 genentech
Rcpp11 genentech
 
PVS-Studio team experience: checking various open source projects, or mistake...
PVS-Studio team experience: checking various open source projects, or mistake...PVS-Studio team experience: checking various open source projects, or mistake...
PVS-Studio team experience: checking various open source projects, or mistake...
 
Vcs16
Vcs16Vcs16
Vcs16
 
JavaSE7 Launch Event: Java7xGroovy
JavaSE7 Launch Event: Java7xGroovyJavaSE7 Launch Event: Java7xGroovy
JavaSE7 Launch Event: Java7xGroovy
 
Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
 
C++ TUTORIAL 7
C++ TUTORIAL 7C++ TUTORIAL 7
C++ TUTORIAL 7
 
JavaScript - Agora nervoso
JavaScript - Agora nervosoJavaScript - Agora nervoso
JavaScript - Agora nervoso
 
Computer graphics programs in c++
Computer graphics programs in c++Computer graphics programs in c++
Computer graphics programs in c++
 
Blocks+gcd入門
Blocks+gcd入門Blocks+gcd入門
Blocks+gcd入門
 
Session07 recursion
Session07 recursionSession07 recursion
Session07 recursion
 

Destacado

coqun
coquncoqun
coqunMoCo7
 
coqun
coquncoqun
coqunMoCo7
 
Prototyping is an attitude
Prototyping is an attitudePrototyping is an attitude
Prototyping is an attitudeWith Company
 
10 Insightful Quotes On Designing A Better Customer Experience
10 Insightful Quotes On Designing A Better Customer Experience10 Insightful Quotes On Designing A Better Customer Experience
10 Insightful Quotes On Designing A Better Customer ExperienceYuan Wang
 
How to Build a Dynamic Social Media Plan
How to Build a Dynamic Social Media PlanHow to Build a Dynamic Social Media Plan
How to Build a Dynamic Social Media PlanPost Planner
 
Learn BEM: CSS Naming Convention
Learn BEM: CSS Naming ConventionLearn BEM: CSS Naming Convention
Learn BEM: CSS Naming ConventionIn a Rocket
 
SEO: Getting Personal
SEO: Getting PersonalSEO: Getting Personal
SEO: Getting PersonalKirsty Hulse
 

Destacado (7)

coqun
coquncoqun
coqun
 
coqun
coquncoqun
coqun
 
Prototyping is an attitude
Prototyping is an attitudePrototyping is an attitude
Prototyping is an attitude
 
10 Insightful Quotes On Designing A Better Customer Experience
10 Insightful Quotes On Designing A Better Customer Experience10 Insightful Quotes On Designing A Better Customer Experience
10 Insightful Quotes On Designing A Better Customer Experience
 
How to Build a Dynamic Social Media Plan
How to Build a Dynamic Social Media PlanHow to Build a Dynamic Social Media Plan
How to Build a Dynamic Social Media Plan
 
Learn BEM: CSS Naming Convention
Learn BEM: CSS Naming ConventionLearn BEM: CSS Naming Convention
Learn BEM: CSS Naming Convention
 
SEO: Getting Personal
SEO: Getting PersonalSEO: Getting Personal
SEO: Getting Personal
 

Similar a coqun

Compilation of COSMO for GPU using LLVM
Compilation of COSMO for GPU using LLVMCompilation of COSMO for GPU using LLVM
Compilation of COSMO for GPU using LLVMLinaro
 
「ガロア表現」を使って素数の分解法則を考える #mathmoring
「ガロア表現」を使って素数の分解法則を考える #mathmoring「ガロア表現」を使って素数の分解法則を考える #mathmoring
「ガロア表現」を使って素数の分解法則を考える #mathmoringJunpei Tsuji
 
El text.life science6.matsubayashi191120
El text.life science6.matsubayashi191120El text.life science6.matsubayashi191120
El text.life science6.matsubayashi191120RCCSRENKEI
 
Deep generative model.pdf
Deep generative model.pdfDeep generative model.pdf
Deep generative model.pdfHyungjoo Cho
 
「Frama-Cによるソースコード検証」 (mzp)
「Frama-Cによるソースコード検証」 (mzp)「Frama-Cによるソースコード検証」 (mzp)
「Frama-Cによるソースコード検証」 (mzp)Hiroki Mizuno
 
Design and analysis of algorithm ppt ppt
Design and analysis of algorithm ppt pptDesign and analysis of algorithm ppt ppt
Design and analysis of algorithm ppt pptsrushtiivp
 
Declarative Type System Specification with Statix
Declarative Type System Specification with StatixDeclarative Type System Specification with Statix
Declarative Type System Specification with StatixEelco Visser
 
Consider the following C code snippet C codevoid setArray(int.pdf
Consider the following C code snippet C codevoid setArray(int.pdfConsider the following C code snippet C codevoid setArray(int.pdf
Consider the following C code snippet C codevoid setArray(int.pdfarihantmum
 
Phase diagram at finite T & Mu in strong coupling limit of lattice QCD
Phase diagram at finite T & Mu in strong coupling limit of lattice QCDPhase diagram at finite T & Mu in strong coupling limit of lattice QCD
Phase diagram at finite T & Mu in strong coupling limit of lattice QCDBenjamin Jaedon Choi
 
Joel Spencer – Finding Needles in Exponential Haystacks
Joel Spencer – Finding Needles in Exponential Haystacks Joel Spencer – Finding Needles in Exponential Haystacks
Joel Spencer – Finding Needles in Exponential Haystacks Yandex
 
Trilinear embedding for divergence-form operators
Trilinear embedding for divergence-form operatorsTrilinear embedding for divergence-form operators
Trilinear embedding for divergence-form operatorsVjekoslavKovac1
 
第13回数学カフェ「素数!!」二次会 LT資料「乱数!!」
第13回数学カフェ「素数!!」二次会 LT資料「乱数!!」第13回数学カフェ「素数!!」二次会 LT資料「乱数!!」
第13回数学カフェ「素数!!」二次会 LT資料「乱数!!」Ken'ichi Matsui
 
Quantitative norm convergence of some ergodic averages
Quantitative norm convergence of some ergodic averagesQuantitative norm convergence of some ergodic averages
Quantitative norm convergence of some ergodic averagesVjekoslavKovac1
 
Slides: Total Jensen divergences: Definition, Properties and k-Means++ Cluste...
Slides: Total Jensen divergences: Definition, Properties and k-Means++ Cluste...Slides: Total Jensen divergences: Definition, Properties and k-Means++ Cluste...
Slides: Total Jensen divergences: Definition, Properties and k-Means++ Cluste...Frank Nielsen
 

Similar a coqun (20)

Compilation of COSMO for GPU using LLVM
Compilation of COSMO for GPU using LLVMCompilation of COSMO for GPU using LLVM
Compilation of COSMO for GPU using LLVM
 
「ガロア表現」を使って素数の分解法則を考える #mathmoring
「ガロア表現」を使って素数の分解法則を考える #mathmoring「ガロア表現」を使って素数の分解法則を考える #mathmoring
「ガロア表現」を使って素数の分解法則を考える #mathmoring
 
El text.life science6.matsubayashi191120
El text.life science6.matsubayashi191120El text.life science6.matsubayashi191120
El text.life science6.matsubayashi191120
 
Shell theory
Shell theoryShell theory
Shell theory
 
Deep generative model.pdf
Deep generative model.pdfDeep generative model.pdf
Deep generative model.pdf
 
Compiling fµn language
Compiling fµn languageCompiling fµn language
Compiling fµn language
 
Randomized smoothing
Randomized smoothingRandomized smoothing
Randomized smoothing
 
「Frama-Cによるソースコード検証」 (mzp)
「Frama-Cによるソースコード検証」 (mzp)「Frama-Cによるソースコード検証」 (mzp)
「Frama-Cによるソースコード検証」 (mzp)
 
Design and analysis of algorithm ppt ppt
Design and analysis of algorithm ppt pptDesign and analysis of algorithm ppt ppt
Design and analysis of algorithm ppt ppt
 
Declarative Type System Specification with Statix
Declarative Type System Specification with StatixDeclarative Type System Specification with Statix
Declarative Type System Specification with Statix
 
Consider the following C code snippet C codevoid setArray(int.pdf
Consider the following C code snippet C codevoid setArray(int.pdfConsider the following C code snippet C codevoid setArray(int.pdf
Consider the following C code snippet C codevoid setArray(int.pdf
 
Phase diagram at finite T & Mu in strong coupling limit of lattice QCD
Phase diagram at finite T & Mu in strong coupling limit of lattice QCDPhase diagram at finite T & Mu in strong coupling limit of lattice QCD
Phase diagram at finite T & Mu in strong coupling limit of lattice QCD
 
Joel Spencer – Finding Needles in Exponential Haystacks
Joel Spencer – Finding Needles in Exponential Haystacks Joel Spencer – Finding Needles in Exponential Haystacks
Joel Spencer – Finding Needles in Exponential Haystacks
 
hw-sol.pdf
hw-sol.pdfhw-sol.pdf
hw-sol.pdf
 
Muchtadi
MuchtadiMuchtadi
Muchtadi
 
Cs262 2006 lecture6
Cs262 2006 lecture6Cs262 2006 lecture6
Cs262 2006 lecture6
 
Trilinear embedding for divergence-form operators
Trilinear embedding for divergence-form operatorsTrilinear embedding for divergence-form operators
Trilinear embedding for divergence-form operators
 
第13回数学カフェ「素数!!」二次会 LT資料「乱数!!」
第13回数学カフェ「素数!!」二次会 LT資料「乱数!!」第13回数学カフェ「素数!!」二次会 LT資料「乱数!!」
第13回数学カフェ「素数!!」二次会 LT資料「乱数!!」
 
Quantitative norm convergence of some ergodic averages
Quantitative norm convergence of some ergodic averagesQuantitative norm convergence of some ergodic averages
Quantitative norm convergence of some ergodic averages
 
Slides: Total Jensen divergences: Definition, Properties and k-Means++ Cluste...
Slides: Total Jensen divergences: Definition, Properties and k-Means++ Cluste...Slides: Total Jensen divergences: Definition, Properties and k-Means++ Cluste...
Slides: Total Jensen divergences: Definition, Properties and k-Means++ Cluste...
 

coqun

  • 1. in $*CcBg $^93 $b$( (twitter ID: @MoCo7) August 29, 2010 in $*CBgc 1/24
  • 2. (M2) : shift/reset ?d?J0Q0w2q : OCaml!$ Coq!$7wO@!$ ect. in $*CBgc 2/24
  • 3. in $*CBgc 3/24
  • 4. : ProofGeneral in $*CBgc 4/24
  • 5. : ProofGeneral in $*CBgc 4/24
  • 6. : ProofGeneral OCaml Meeting $N talker $N 1 ?M in $*CBgc 4/24
  • 7. : ProofGeneral OCaml Meeting $N talker $N 1 ?M ⇑ <TI.$NK3 in $*CBgc 4/24
  • 8. D1 1 ?M M2 4 ?M M1 2 ?M B4 1 ?M in $*CBgc 5/24
  • 9. Coq %<_ 2008 G/A04|3+:E Coq $rJY6/$7$h$& ! $H&%<_G7$? : 1 install!$4?t!$Bg0hE?t!$ X JQ* Specification $NDj5A 2 3 4 implication 0J30$NO@M}1i;!$Ey<0$N>ZL@ ; 5 6 7 (TAPL 8 !$ >O soundness) http://pllab.is.ocha.ac.jp/lab.html in $*CBgc 6/24
  • 10. = BjL? %`i0mW = L@>Z in $*CBgc 7/24
  • 11. /)◦∀◦( yay! /)◦∀◦( = BjL? %`i0mW = L@>Z (◦∀◦)/ yay! (◦∀◦)/ in $*CBgc 7/24
  • 12. Coq 3Z$7$=$& in $*CBgc 7/24
  • 13. Coq 3Z$7$=$& : CPDT M2 $O8&5f$K Coq $r;H$($F$J ... ! (;$?$ H !) in $*CBgc 7/24
  • 14. Coq 3Z$7h Coq ICFP2009 $N B. C. Pierce $N>7BT9V1i “Lambda, the Ultimate TA: Using a Proof Assistant to Teach Programming Language Foundations” from Theory of PL for PL geeks to Software Foundation to the masses http://www.cis.upenn.edu/~bcpierce/sf in $*CBgc 9/24
  • 15. : @h@8C#$,9%$-J3Hr$d$k ... functional derivation $N<jK!$G?'!9$J %;^s%F%/%9$N%$s%?%Wj?$rF3$/ # in $*CBgc 10/24
  • 16. { 0z$-;→;MB'1i$ } %$s?Wjr ... reduction semantics =q$/ $G CPS 49 JQ factorial 4X?t$d fibonacci 4X?t$r ... CPS 49 JQ in $*CBgc 11/24
  • 17. factorial 4X?t (CPS) let rec fac n = if n <= 0 then 1 else n * fac ( n - 1 ) let rec fac_cps n k = if n <= 0 then k 1 else fac_cps ( n - 1 ) ( fun x - > k ( n * x ) ) let main n = fac_cps n ( fun x - > x ) in $*CBgc 12/24
  • 18. factorial 4X?t (Hs4X?t2= ) type cont = C0 | C1 of int * cont let rec apply k x = match k with | C0 - > x | C1 (n , k ) - > apply k ( n * x ) let rec fac_defunc n k = if n <= 0 then apply k 1 else fac_defunc ( n - 1 ) ( C1 (n , k ) ) let main n = fac_defunc n C0 in $*CBgc 13/24
  • 19. y (?) ~ Coq $G!# in $*CBgc 14/24
  • 20. !! in $*CBgc 15/24
  • 21. !! in $*CBgc 15/24
  • 22. CPS JQ49$N@5Ev- (factorial) Theorem ∀n ∈ N, f acds n = f accps n id in $*CBgc 16/24
  • 23. CPS JQ49$N@5Ev- (factorial) Theorem ∀n ∈ N, f acds n = f accps n id Lemma ∀n ∈ N, k ∈ N → N, k (f acds n) = f accps n k >ZL@ : n $K4X$9$k5"G<K! in $*CBgc 16/24
  • 24. CPS JQ49$N@5Ev- (factorial) Theorem ∀n ∈ N, f acds n = f accps n id Lemma ∀n ∈ N, k ∈ N → N, k (f acds n) = f accps n k >ZL@ : n $K4X$9$k5"G<K! >e$NDjM}$O k = id $K$9$l$P<($,$k in $*CBgc 16/24
  • 25. (factorial) Theorem ∀n ∈ N, f accps n id = f acdef unc n C0 in $*CBgc 17/24
  • 26. (factorial) Theorem ∀n ∈ N, f accps n id = f acdef unc n C0 Lemma ∀n ∈ N, k ∈ N → N, c ∈ cont, (∀a ∈ N, k a = apply c a) → f accps n k = f acdef unc n c >ZL@ : n $K4X$9$k5"G<K! in $*CBgc 17/24
  • 27. (factorial) Theorem ∀n ∈ N, f accps n id = f acdef unc n C0 Lemma ∀n ∈ N, k ∈ N → N, c ∈ cont, (∀a ∈ N, k a = apply c a) → f accps n k = f acdef unc n c >ZL@ : n $K4X$9$k5"G<K! >e$NDjM}$O k = id!$ c = C0 $K $9$l$P<($;$k in $*CBgc 17/24
  • 28. CPS JQ49 & Hs4X?t2=$N@5Ev- (fibonacci) let rec fib n = if n <= 1 then 1 else fib ( n - 1 ) + fib ( n - 2 ) : $[“ factorial $HF1$83J9% : well founded induction $G4hD%$k in $*CBgc 18/24
  • 29. CPS JQ49 & Hs4X?t2=$N@5Ev- (fibonacci) let rec fib n = if n <= 1 then 1 else fib ( n - 1 ) + fib ( n - 2 ) : $[“ factorial $HF1$83J9% : well founded induction $G4hD%$k ?? apply 4X?t$HAj8_:F5”$N7A$K$Jj Coq $G>e<j$/Dj5A=PMh$J$ ... (>ZL@$bH~$7$/$J ) in $*CBgc 18/24
  • 30. fibonacci (CPS, OCaml) let rec fib_cps n k = if n < 2 then k 1 else fib_cps ( n - 1 ) ( fun x - > fib_cps ( n - 2 ) ( fun y - > k ( x + y ) ) ) in $*CBgc 19/24
  • 31. fibonacci (defunctionalized, OCaml) type cont = | C0 | C1 of int * cont_t | C2 of int * cont_t let rec apply k x = match k with | C0 - > x | C1 (n , k ) - > fib_defunc ( n - 2 ) ( C2 (x , k ) ) | C2 ( n1 , k ) - > apply k ( n1 + x ) and fib_defunc n k = if n < 2 then apply k 1 else fib_defunc ( n - 1 ) ( C1 (n , k ) ) in $*CBgc 20/24
  • 32. fibonacci (Coq) Fixpoint app ( k : cont_fib ) ( x : nat ) ( count : nat ) { struct count } : option nat : = match count with | O = > None | S count ’ = > match k with | C0_fib = > Some x | C1_fib n k = > fib_defunc ( minus n 1 ) ( C2_fib x k ) count ’ | C2_fib n1 k = > app k ( plus n1 x ) count ’ end end with fib_defunc ( n : nat ) ( k : cont_fib ) ( count : nat ) { struct count } : option nat : = match count with | O = > None | S count ’ = > match n with | O | S O = > app k 1 count ’ | S m = > fib_defunc m ( C1_fib m k ) count ’ end end . in $*CBgc 21/24
  • 33. D1 $N@hGZ : Coqer ··· M1 $N8eGZ : Coqer / Agdar · · · functional derivation $N>ZL@ (:#$O Agda 6/Cf JY ) in $*CBgc 22/24
  • 34. : shift/reset $ND>@“<BAu Caml Light $K shift/reset F3F~ functional derivation $NK!$rMxM$7$F!$ <j Q definitional interpreter =⇒ ZINC $N>ZL@ Coq $r$?$ ;H ... $b + ? Coq $r$?$ ;H ... $b + ?? in $*CBgc 23/24
  • 35. u u h ¤ h ¤ h in $*CBgc 24/24