SlideShare a Scribd company logo
Math::Category
id:hiratara

2009-11-21
Math::Category   (1)


✤   Perl

✤




✤




✤
Math::Category           (2)

✤




    ✤   dom, cod, comp

✤




    ✤        Hom

✤
(1)

✤




✤




✤   Morphism                      interface

    ✤   source: dom           Morphism

    ✤   target: cod          Morphism

    ✤   composition:
(2)

✤




    ✤   target source

    ✤   composition

✤




    ✤




    ✤
(1): SimpleMorphism

✤   2                      1

✤   simple_morph ‘1’ => ‘2’;                           ‘1’

    ✤   source   simple_morph ‘1’ => ‘1’                        ‘2’

    ✤   target   simple_morph ‘2’ => ‘2’                              ‘3’

    ✤   (simple_morph ‘2’ => ‘3’) . (simple_morph ‘1’ => ‘2’)
        = (simple_morph ‘1’ => ‘3’)
(2): SubroutineMorphism(1)

✤   Perl

✤   Perl

    ✤


                                                           print
✤   sub_morph { $_[0] * 2 }
                                                              undef
✤   source target             sub_morph { @_ } (   )

    ✤                                                  (      )
(2): SubroutineMorphism(2)


✤       $sub2 . $sub1   $sub1   $sub2

    ✤




    ✤




✤
(1)

✤   f.(g.h)        (f . g) . h    f       g       h

    ✤




    ✤   id                            (       )

✤




    ✤   f×g: x → ( f(x), g(x) )
(2)

A×B              πA πB                          C
( f, g ): f, g                       2

                         f                                           g
                                         ( f, g )




         A               πA
                                          A×B                   πB
                                                                           B
                 (f,g)       f   g
                                                    (f,g)   (g,f)
(3):

✤          : bi_morph $morph1, $morph2;   (A1, A2)
    ✤   source target                            (f, g)

                                               (B1, B2)
✤          : op $morph;
                                           B
    ✤   source targe                            f
    ✤   op op $morph;     $morph
                                                     A
(1)


✤   Functor

    ✤




    ✤   Morphism         Morphism

✤


    (                               )
(2)


✤            functor { ... };

    ✤


        (Morphism                  OK)

    ✤




✤                                ( $functor2 . $functor1 )
(1): $BI_FUNCTOR


✤   Hom(-, -)

    ✤   C^op × C      Sets

    ✤   C^op × C

    ✤   Sets    SubroutineMorphism
        (                            Sets   )
(1)



✤   NaturalTransformation

    ✤




    ✤                             (Morphism)
(2)

✤               nat { };

    ✤




    ✤




    ✤       (      )

        ✤
(3)


✤




    ✤   $nat2 . $nat1

    ✤   $funct . $nat


    ✤   $nat . $funct
(4): FunctorMorphism

✤




✤   functor_morph nat {               F
      my $id = shift;
      ...  ...
         return $sum_morph
                                          τ
    };

✤   source target            source
                                              G
         target
(2): $YONEDA_EMBEDDING


✤




    ✤   C^op           Sets^C

    ✤          Hom(g, -)
: CPS   (1)

✤   uc   CPS
: CPS            (2)




                                 Sets
      Hom(        , -)    Hom(          , undef)
                                                   ∈
                                                        print




uc   $fun_morph           $cps_uc
                                               $cps_uc->(print)




                                              ∈
      Hom(        , -)    Hom(          , undef)
Monad                            (1)

✤             functor            eta   mu

    ✤   eta: I → T, mu: TT → T

    ✤




✤   Haskell                                 Monad

    ✤
Monad                      (2)

✤           1.
    $monad->mu . (funct_nat $monad->functor, $monad->eta)
    $monad->mu . (nat_funct $monad->eta, $monad->functor)
            T→T

✤           2.
    $monad->mu . (funct_nat $monad->functor, $monad->mu)
    $monad->mu . (nat_funct $monad->mu, $monad->functor)
           (         TTT → T           )
Monad                     (1): $LIST_MONAD


✤




✤


    [v1_1, v1_2, v1_3], [v2_1, v2_2], [v3_1, v3_2, v3_3, v3_4]


✤            map eta       []              mu     concat
Monad                     (2): $STATE_MONAD


✤




✤


    sub { my @states = @_; ..    .. return ¥@values, ¥@new_states }
                  1

✤   functor, eta, mu   Haskell                     (                  )
Monad           (3): Maybe



✤   Maybe           nothing

✤           (   )             null

✤   List
(5): KleisliMorphism

✤        m       f: a -> m b        b


mma                            mmb            mmc
                                         mg
                                                   μc


ma                             mb             mc
             f                           g
    ηa                              ηb             ηc

a                               b              c
(5): KleisliMorphism

✤        m       f: a -> m b        b


mma                            mmb            mmc
                                         mg
                                                   μc


ma                             mb             mc
             f                           g
    ηa                              ηb             ηc

a                               b              c
Kleisli                                   : Maybe                    (1)


✤                               HTML
    get_number: HTML                           (<span>3/10</span>)
    cut_tag:                (3/10)
    parse_number:               (3, 10)
    div:            (0.3)
                                           

✤                   NG
Kleisli   : Maybe   (2)

✤
Kleisli
 
                                  : Maybe   (2)
    
    
    
       
    
       
✤
Kleisli               : Maybe   (2)

✤   Maybe   Kleisli
Kleisli                   : Maybe   (2)

✤       Maybe   Kleisli
✤




✤




    ✤




    ✤       (   )

        ✤

More Related Content

PDF
Hacking parse.y (RubyConf 2009)
KEY
Javascript - The core
PPTX
ภาษาซี
PPTX
ภาษาซี
ODT
linieaire regressie
PDF
Git入門
PDF
モナモナ言うモナド入門.tar.gz
PDF
モデルから知るGit
Hacking parse.y (RubyConf 2009)
Javascript - The core
ภาษาซี
ภาษาซี
linieaire regressie
Git入門
モナモナ言うモナド入門.tar.gz
モデルから知るGit

Viewers also liked (20)

PDF
すべてが@__kanになる
KEY
Perl saved a lady.
PDF
Stateモナドの解説 中編
PDF
20120526 hachioji.pm
KEY
Hachioji.pm in Machida の LT
PDF
Types and perl language
KEY
TraitとMoose::Role
PDF
カレーとHokkaidopm
KEY
Stateモナドの解説 前編
PDF
Stateモナドの解説 後編
KEY
定理3
PDF
Monads in perl
PDF
ウヰスキーとPSGI
PDF
レンズ (ぶつかり稽古の没プレゼン)
PDF
AnyEvent and Plack
KEY
Arrows in perl
KEY
循環参照のはなし
PDF
Levenshtein Automata
PDF
Monads in python
PDF
モナモナ言うモナド入門
すべてが@__kanになる
Perl saved a lady.
Stateモナドの解説 中編
20120526 hachioji.pm
Hachioji.pm in Machida の LT
Types and perl language
TraitとMoose::Role
カレーとHokkaidopm
Stateモナドの解説 前編
Stateモナドの解説 後編
定理3
Monads in perl
ウヰスキーとPSGI
レンズ (ぶつかり稽古の没プレゼン)
AnyEvent and Plack
Arrows in perl
循環参照のはなし
Levenshtein Automata
Monads in python
モナモナ言うモナド入門
Ad

Similar to Math::Category (20)

PDF
Data type a la carte
KEY
Coqによる暗号アルゴリズムの実装の安全性検証
PDF
Program Language - Fall 2013
PDF
Lp fp us with multispeculative techniques_19_12_12
PDF
CVPR2010: higher order models in computer vision: Part 3
PDF
PHP.next: Traits
PDF
Chapter 9 : Polymorphism, Dynamic Typing, and Dynamic Binding
KEY
Haskellで学ぶ関数型言語
PDF
Algebraic Data Types and Origami Patterns
PDF
Encoding syntactic dependencies by vector permutation
PDF
Traversing on Algebraic Datatype
PDF
Functional Programming In Mathematica
PDF
A type system for the vectorial aspects of the linear-algebraic lambda-calculus
PDF
Intro To Agda
PPTX
Domain Transformations
PPTX
Parsing using graphs
PDF
A Study on Compositional Semantics of Words in Distributional Spaces
PPTX
Class 11: Deeper List Procedures
PDF
Peyton jones-2011-type classes
PPT
Functional Pe(a)rls version 2
Data type a la carte
Coqによる暗号アルゴリズムの実装の安全性検証
Program Language - Fall 2013
Lp fp us with multispeculative techniques_19_12_12
CVPR2010: higher order models in computer vision: Part 3
PHP.next: Traits
Chapter 9 : Polymorphism, Dynamic Typing, and Dynamic Binding
Haskellで学ぶ関数型言語
Algebraic Data Types and Origami Patterns
Encoding syntactic dependencies by vector permutation
Traversing on Algebraic Datatype
Functional Programming In Mathematica
A type system for the vectorial aspects of the linear-algebraic lambda-calculus
Intro To Agda
Domain Transformations
Parsing using graphs
A Study on Compositional Semantics of Words in Distributional Spaces
Class 11: Deeper List Procedures
Peyton jones-2011-type classes
Functional Pe(a)rls version 2
Ad

Recently uploaded (20)

PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Encapsulation theory and applications.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
cuic standard and advanced reporting.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Empathic Computing: Creating Shared Understanding
PDF
Getting Started with Data Integration: FME Form 101
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Electronic commerce courselecture one. Pdf
PPTX
A Presentation on Artificial Intelligence
PDF
A comparative analysis of optical character recognition models for extracting...
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
Encapsulation theory and applications.pdf
Unlocking AI with Model Context Protocol (MCP)
NewMind AI Weekly Chronicles - August'25-Week II
cuic standard and advanced reporting.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Empathic Computing: Creating Shared Understanding
Getting Started with Data Integration: FME Form 101
Building Integrated photovoltaic BIPV_UPV.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Programs and apps: productivity, graphics, security and other tools
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Electronic commerce courselecture one. Pdf
A Presentation on Artificial Intelligence
A comparative analysis of optical character recognition models for extracting...
20250228 LYD VKU AI Blended-Learning.pptx

Math::Category

  • 2. Math::Category (1) ✤ Perl ✤ ✤ ✤
  • 3. Math::Category (2) ✤ ✤ dom, cod, comp ✤ ✤ Hom ✤
  • 4. (1) ✤ ✤ ✤ Morphism interface ✤ source: dom Morphism ✤ target: cod Morphism ✤ composition:
  • 5. (2) ✤ ✤ target source ✤ composition ✤ ✤ ✤
  • 6. (1): SimpleMorphism ✤ 2 1 ✤ simple_morph ‘1’ => ‘2’; ‘1’ ✤ source simple_morph ‘1’ => ‘1’ ‘2’ ✤ target simple_morph ‘2’ => ‘2’ ‘3’ ✤ (simple_morph ‘2’ => ‘3’) . (simple_morph ‘1’ => ‘2’) = (simple_morph ‘1’ => ‘3’)
  • 7. (2): SubroutineMorphism(1) ✤ Perl ✤ Perl ✤ print ✤ sub_morph { $_[0] * 2 } undef ✤ source target sub_morph { @_ } ( ) ✤ ( )
  • 8. (2): SubroutineMorphism(2) ✤ $sub2 . $sub1 $sub1 $sub2 ✤ ✤ ✤
  • 9. (1) ✤ f.(g.h) (f . g) . h f g h ✤ ✤ id ( ) ✤ ✤ f×g: x → ( f(x), g(x) )
  • 10. (2) A×B πA πB C ( f, g ): f, g 2 f g ( f, g ) A πA A×B πB B (f,g) f g (f,g) (g,f)
  • 11. (3): ✤ : bi_morph $morph1, $morph2; (A1, A2) ✤ source target (f, g) (B1, B2) ✤ : op $morph; B ✤ source targe f ✤ op op $morph; $morph A
  • 12. (1) ✤ Functor ✤ ✤ Morphism Morphism ✤ ( )
  • 13. (2) ✤ functor { ... }; ✤ (Morphism OK) ✤ ✤ ( $functor2 . $functor1 )
  • 14. (1): $BI_FUNCTOR ✤ Hom(-, -) ✤ C^op × C Sets ✤ C^op × C ✤ Sets SubroutineMorphism ( Sets )
  • 15. (1) ✤ NaturalTransformation ✤ ✤ (Morphism)
  • 16. (2) ✤ nat { }; ✤ ✤ ✤ ( ) ✤
  • 17. (3) ✤ ✤ $nat2 . $nat1 ✤ $funct . $nat ✤ $nat . $funct
  • 18. (4): FunctorMorphism ✤ ✤ functor_morph nat { F my $id = shift; ... ... return $sum_morph τ }; ✤ source target source G target
  • 19. (2): $YONEDA_EMBEDDING ✤ ✤ C^op Sets^C ✤ Hom(g, -)
  • 20. : CPS (1) ✤ uc CPS
  • 21. : CPS (2) Sets Hom( , -) Hom( , undef) ∈ print uc $fun_morph $cps_uc $cps_uc->(print) ∈ Hom( , -) Hom( , undef)
  • 22. Monad (1) ✤ functor eta mu ✤ eta: I → T, mu: TT → T ✤ ✤ Haskell Monad ✤
  • 23. Monad (2) ✤ 1. $monad->mu . (funct_nat $monad->functor, $monad->eta) $monad->mu . (nat_funct $monad->eta, $monad->functor) T→T ✤ 2. $monad->mu . (funct_nat $monad->functor, $monad->mu) $monad->mu . (nat_funct $monad->mu, $monad->functor) ( TTT → T )
  • 24. Monad (1): $LIST_MONAD ✤ ✤ [v1_1, v1_2, v1_3], [v2_1, v2_2], [v3_1, v3_2, v3_3, v3_4] ✤ map eta [] mu concat
  • 25. Monad (2): $STATE_MONAD ✤ ✤ sub { my @states = @_; .. .. return ¥@values, ¥@new_states } 1 ✤ functor, eta, mu Haskell ( )
  • 26. Monad (3): Maybe ✤ Maybe nothing ✤ ( ) null ✤ List
  • 27. (5): KleisliMorphism ✤ m f: a -> m b b mma mmb mmc mg μc ma mb mc f g ηa ηb ηc a b c
  • 28. (5): KleisliMorphism ✤ m f: a -> m b b mma mmb mmc mg μc ma mb mc f g ηa ηb ηc a b c
  • 29. Kleisli : Maybe (1) ✤ HTML get_number: HTML (<span>3/10</span>) cut_tag: (3/10) parse_number: (3, 10) div: (0.3) ✤ NG
  • 30. Kleisli : Maybe (2) ✤
  • 31. Kleisli : Maybe (2) ✤
  • 32. Kleisli : Maybe (2) ✤ Maybe Kleisli
  • 33. Kleisli : Maybe (2) ✤ Maybe Kleisli
  • 34. ✤ ✤ ✤ ✤ ( ) ✤