SlideShare a Scribd company logo
1 of 34
Download to read offline
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

Viewers also liked

すべてが@__kanになる
すべてが@__kanになるすべてが@__kanになる
すべてが@__kanになるMasahiro Honma
 
Stateモナドの解説 中編
Stateモナドの解説 中編Stateモナドの解説 中編
Stateモナドの解説 中編Masahiro Honma
 
Hachioji.pm in Machida の LT
Hachioji.pm in Machida の LTHachioji.pm in Machida の LT
Hachioji.pm in Machida の LTMasahiro Honma
 
Types and perl language
Types and perl languageTypes and perl language
Types and perl languageMasahiro Honma
 
カレーとHokkaidopm
カレーとHokkaidopmカレーとHokkaidopm
カレーとHokkaidopmMasahiro Honma
 
Stateモナドの解説 前編
Stateモナドの解説 前編Stateモナドの解説 前編
Stateモナドの解説 前編Masahiro Honma
 
Stateモナドの解説 後編
Stateモナドの解説 後編Stateモナドの解説 後編
Stateモナドの解説 後編Masahiro Honma
 
ウヰスキーとPSGI
ウヰスキーとPSGIウヰスキーとPSGI
ウヰスキーとPSGIMasahiro Honma
 
レンズ (ぶつかり稽古の没プレゼン)
レンズ (ぶつかり稽古の没プレゼン)レンズ (ぶつかり稽古の没プレゼン)
レンズ (ぶつかり稽古の没プレゼン)Masahiro Honma
 
循環参照のはなし
循環参照のはなし循環参照のはなし
循環参照のはなしMasahiro Honma
 
Monads in python
Monads in pythonMonads in python
Monads in pythoneldariof
 
モナモナ言うモナド入門
モナモナ言うモナド入門モナモナ言うモナド入門
モナモナ言うモナド入門Masahiro Honma
 

Viewers also liked (20)

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

Recently uploaded

Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 

Recently uploaded (20)

Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 

Perl Math Category Module Provides Category Theory Concepts

  • 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. ✤ ✤ ✤ ✤ ( ) ✤