SlideShare a Scribd company logo
1 of 158
Download to read offline
TPP 2012 at Chiba, Nov 21, 2012




       Coq に於ける
Monads with Predicate Liftings
       の実装と考察


      千葉大学大学院 理学研究科 須田 啓司
正確には
Kleisli Triples with Predicate Liftings
                の実装です
各々の道具の中身よりも
それらの関係性に重点を置きます
op
                     :C        ! Cat


                  hT, ⌘, µ, ⌧, ✓, ⌫i        hT , ⌘, µi
       各々の道具の中身よりも
     それらの関係性に重点を置きます
  Kl(T )                                     Kl(T )


           #              #            ⇧
hT, ⌘, ( ) i   hT, ⌘, ( ) , ⌧, ✓, ( ) i    hT , ⌘, ( )# i
各々の道具の中身よりも
それらの関係性に重点を置きます
はじめに
モナド on Coq
‣ 関数型プログラミングの文脈に於けるモナド
- 手続き的にプログラムを記述するための枠組み
- 計算効果を統一的に扱うことを可能にする
‣ 型クラスとしてのモナド
- 型変換子Tでパラメタライズされた型クラス
- モナド則をメンバとして持つ
 • モナドそのものを推論の対象と出来る
- 個々の計算効果はモナドのサブクラスとして記述される
 • 失敗,状態,非決定性など
Record TypeModifier: Type :=
 {
   tm_modify :> Set -> Set;
   tm_equivalence {A: Set}: Equivalence (tm_modify A)
 }.

Notation "A =t= B" := (equiv_eq (Equivalence:=tm_equivalence _) A B)
 (at level 70, no associativity).

Reserved Notation "x >>= y" (at level 60, left associativity).
Class Monad (T: TypeModifier):=
 {
   ret {A: Set}: A -> T A;

  bind {A B: Set}: (A -> T B) -> T A -> T B
   where "x >>= y" := (bind y x);

  unit_left:
   forall (A B: Set)(f: A -> T B)(a: A),
    (ret a) >>= f =t= f a;
  unit_right:
   forall (A: Set)(m: T A),
    m >>= ret =t= m;
  assoc:
   forall (A B C: Set)(f: A -> T B)(g: B -> T C)(m: T A),
    (m >>= f >>= g) =t= m >>= (fun x => (f x) >>= g);

   bind_subst:
    forall (A B: Set)(m m': T A)(f f': A -> T B),
      m =t= m' ->
      (forall a: A, f a =t= f' a) ->
      m >>= f =t= m' >>= f'
 }.
Record TypeModifier: Type :=
 {
   tm_modify :> Set -> Set;
   tm_equivalence {A: Set}: Equivalence (tm_modify A)
 }.

Notation "A =t= B" := (equiv_eq (Equivalence:=tm_equivalence _) A B)
 (at level 70, no associativity).

Reserved Notation "x >>= y" (at level 60, left associativity).
Class Monad (T: TypeModifier):=
 {
   ret {A: Set}: A -> T A;

  bind {A B: Set}: (A -> T B) -> T A -> T B
   where "x >>= y" := (bind y x);

  unit_left:
   forall (A B: Set)(f: A -> T B)(a: A),
    (ret a) >>= f =t= f a;
  unit_right:
   forall (A: Set)(m: T A),
    m >>= ret =t= m;
  assoc:
   forall (A B C: Set)(f: A -> T B)(g: B -> T C)(m: T A),
    (m >>= f >>= g) =t= m >>= (fun x => (f x) >>= g);

   bind_subst:
    forall (A B: Set)(m m': T A)(f f': A -> T B),
      m =t= m' ->
      (forall a: A, f a =t= f' a) ->
      m >>= f =t= m' >>= f'
 }.
Record TypeModifier: Type :=
 {
   tm_modify :> Set -> Set;
   tm_equivalence {A: Set}: Equivalence (tm_modify A)
 }.

Notation "A =t= B" := (equiv_eq (Equivalence:=tm_equivalence _) A B)
 (at level 70, no associativity).

Reserved Notation "x >>= y" (at level 60, left associativity).
Class Monad (T: TypeModifier):=
 {
   ret {A: Set}: A -> T A;

  bind {A B: Set}: (A -> T B) -> T A -> T B
   where "x >>= y" := (bind y x);

  unit_left:
   forall (A B: Set)(f: A -> T B)(a: A),
    (ret a) >>= f =t= f a;                                               モナド則
  unit_right:
   forall (A: Set)(m: T A),                                      (Kleisli Tripleの3等式)
    m >>= ret =t= m;
  assoc:
   forall (A B C: Set)(f: A -> T B)(g: B -> T C)(m: T A),
    (m >>= f >>= g) =t= m >>= (fun x => (f x) >>= g);

   bind_subst:
    forall (A B: Set)(m m': T A)(f f': A -> T B),
      m =t= m' ->
      (forall a: A, f a =t= f' a) ->
      m >>= f =t= m' >>= f'
 }.
Record TypeModifier: Type :=
 {
   tm_modify :> Set -> Set;
   tm_equivalence {A: Set}: Equivalence (tm_modify A)
 }.

Notation "A =t= B" := (equiv_eq (Equivalence:=tm_equivalence _) A B)
 (at level 70, no associativity).

Reserved Notation "x >>= y" (at level 60, left associativity).
Class Monad (T: TypeModifier):=
 {
   ret {A: Set}: A -> T A;

  bind {A B: Set}: (A -> T B) -> T A -> T B
   where "x >>= y" := (bind y x);

  unit_left:
   forall (A B: Set)(f: A -> T B)(a: A),
    (ret a) >>= f =t= f a;                                               モナド則
  unit_right:
   forall (A: Set)(m: T A),                                      (Kleisli Tripleの3等式)
    m >>= ret =t= m;
  assoc:
   forall (A B C: Set)(f: A -> T B)(g: B -> T C)(m: T A),
    (m >>= f >>= g) =t= m >>= (fun x => (f x) >>= g);

   bind_subst:
    forall (A B: Set)(m m': T A)(f f': A -> T B),
      m =t= m' ->                                                モナド自体も推論の対象
      (forall a: A, f a =t= f' a) ->
      m >>= f =t= m' >>= f'
 }.
Record TypeModifier: Type :=
 {
   tm_modify :> Set -> Set;
   tm_equivalence {A: Set}: Equivalence (tm_modify A)
 }.

Notation "A =t= B" := (equiv_eq (Equivalence:=tm_equivalence _) A B)
 (at level 70, no associativity).

Reserved Notation "x >>= y" (at level 60, left associativity).
Class Monad (T: TypeModifier):=
 {
   ret {A: Set}: A -> T A;

  bind {A B: Set}: (A -> T B) -> T A -> T B
   where "x >>= y" := (bind y x);

  unit_left:
   forall (A B: Set)(f: A -> T B)(a: A),
    (ret a) >>= f =t= f a;                                               モナド則
  unit_right:
   forall (A: Set)(m: T A),                                      (Kleisli Tripleの3等式)
    m >>= ret =t= m;
  assoc:
   forall (A B C: Set)(f: A -> T B)(g: B -> T C)(m: T A),
    (m >>= f >>= g) =t= m >>= (fun x => (f x) >>= g);

   bind_subst:

                                                                   等式推論のみ
    forall (A B: Set)(m m': T A)(f f': A -> T B),
      m =t= m' ->                                                モナド自体も推論の対象
      (forall a: A, f a =t= f' a) ->
      m >>= f =t= m' >>= f'
 }.
モナドと推論
‣ 等式推論では
- プログラムmと,性質Pを満たすことが 容易にわかる プ
 ログラムnとの間の等価性を示す.
- 間接的な方法
‣ 述語を使いたい
- プログラムmが性質Pを満たす という形の直接的記述
 • 特に,bind記法に倣って次のように書きたい.

            x   m; (P x)
モナドと述語論理
‣ (圏論的な)モナドと述語論理に関する研究
- Evaluation Logic. A.M.Pitts. 1990.
 • 計算型付ラムダ計算を,その上の述語論理へ拡張
- A Semantics for Evaluation Logic. E.Moggi. 1993.
 • モナドによる計算型付ラムダ計算の意味論を,交わり半束
   などを用いて,Evaluation Logicの意味論へと拡張
- Predicate Logic for Functors and Monads. B.Jacobs. 2010
 • 述語の一般化とも言える添字付圏と,Predicate Liftingを用
   いて,モナドのKleisli圏(や代数)の述語の圏を構成
モナドと述語論理
‣ (圏論的な)モナドと述語論理に関する研究
- Evaluation Logic. A.M.Pitts. 1990.
 • 計算型付ラムダ計算を,その上の述語論理へ拡張
- A Semantics for Evaluation Logic. E.Moggi. 1993.
 • モナドによる計算型付ラムダ計算の意味論を,交わり半束
   などを用いて,Evaluation Logicの意味論へと拡張
- Predicate Logic for Functors and Monads. B.Jacobs. 2010
 • 述語の一般化とも言える添字付圏と,Predicate Liftingを用
   いて,モナドのKleisli圏(や代数)の述語の圏を構成
モナドと述語論理
‣ (圏論的な)モナドと述語論理に関する研究
- Evaluation Logic. A.M.Pitts. 1990.
 • 計算型付ラムダ計算を,その上の述語論理へ拡張
Kleisli Tripleの言葉に言い換え,
- A Semantics for Evaluation Logic. E.Moggi. 1993.
Coqで実装するのが本発表の目的
 • モナドによる計算型付ラムダ計算の意味論を,交わり半束
   などを用いて,Evaluation Logicの意味論へと拡張
- Predicate Logic for Functors and Monads. B.Jacobs. 2010
 • 述語の一般化とも言える添字付圏と,Predicate Liftingを用
   いて,モナドのKleisli圏(や代数)の述語の圏を構成
流れ
圏論的準備
- モナドやKleisli圏,添字付圏など
Predicate Liftingの定義
- 函手,モナドとPredicate Lifting
Grothendieck構成とPredicate Lifting
- 述語の圏 の構成
Kleisli Triples with Predicate Liftings
- Coqで実装するための議論と結果
圏論的準備
Kleisli Triple
‣ 圏C上のKleisli Triple
 - 次のものからなる三つ組 hT, ⌘, ( )# i
  • 対象の割り当て
  • 射の族
  • 射の族
 - これらは以下の等式を満たす


‣ HaskellやCoqのモナドクラスの実体はこれ
モナド
‣ 圏C上のモナド
 - 自己函手と2つの自然変換からなる三つ組


 - 次の図式を可換にする(モナド則)




‣ Kleisli Tripleと同値
 -                    として互いを構成可能
Kleisli圏
‣ モナドTのKleisli圏Kl(T)
 - 圏C上のモナド    から以下のように構成する
  • 対象は圏Cの対象と同じ
  • 射      はCの射
  •            の合成射はCの射
  • 恒等射は
  • 圏の公理はモナド則によって与えられる
 - プログラムはKleisli圏の射として解釈される
添字付圏
‣ 添字付圏         : C op ! Cat
 - 例えば
‣ 圏IndCat
 - 添字付圏全体からなる2-圏
 - 射(1-cell)
  • 
 - 射の変換(2-cell)
  • 
添字付圏
‣ 添字付圏         : C op ! Cat
 - 例えば
‣ 圏IndCat
 - 添字付圏全体からなる2-圏
 - 射(1-cell)
  • 
 - 射の変換(2-cell)
  • 
添字付圏
‣ 添字付圏         : C op ! Cat
 - 例えば
‣ 圏IndCat
 - 添字付圏全体からなる2-圏
 - 射(1-cell)
  • 
 - 射の変換(2-cell)
  • 
ここまでに出てきたもの



                     op
                :C        ! Cat




   Kl(T )


            #
 hT, ⌘, ( ) i
Predicate Liftingの定義
函手とP.L.
‣ Functors with Predicate Liftings
 - IndCatに於ける自己射       のこと
 -       をpredicate liftingと呼ぶ
   • X上の述語     をFX上の述語         に
函手とP.L.
‣ Functors with Predicate Liftings
 - IndCatに於ける自己射       のこと
 -       をpredicate liftingと呼ぶ
   • X上の述語     をFX上の述語         に




      (   : C op ! Cat)   (F, )   /(   : C op ! Cat)
函手とP.L.
‣ Functors with Predicate Liftings
 - IndCatに於ける自己射       のこと
 -       をpredicate liftingと呼ぶ
   • X上の述語     をFX上の述語         に
                         op        op
                     C         C
                                       F
                                   ✏
                              +3 C op

                     ✏         ✏
                    Cat       Cat
モナドとP.L.
‣ Monads with Predicate Liftings
 - IndCatの自己射(1-cell)と2つの2-cellからなる三つ組
   • 




 - Predicate Liftingのsplitness
   •    が全て恒等射であるときsplitであるという
            ✓X,P : P ⇠
                     =      (⌘X )(⌧X (P ))
            ⌫X,P   : ⌧T X (⌧X (P )) ⇠ (µX )(⌧X (P ))
                                    =
モナドとP.L.
‣ Monads with Predicate Liftings
 - IndCatの自己射(1-cell)と2つの2-cellからなる三つ組
   • 
        T : C ! C, ⌧ : ) T
        ⌘ : Id ) T, ✓ = {✓X : Id (X) ) (⌘X )⌧X }
        µ : T 2 ) T, ⌫ = {⌫X : ⌧T X ⌧X ) (µX )⌧X }
 - Predicate Liftingのsplitness
   •    が全て恒等射であるときsplitであるという
            ✓X,P : P ⇠
                     =      (⌘X )(⌧X (P ))
            ⌫X,P   : ⌧T X (⌧X (P )) ⇠ (µX )(⌧X (P ))
                                    =
モナド with P.L. のモナド則
モナド with P.L. のモナド則
モナド with P.L. のモナド則



               µX     ⌘T X = idT X
モナド with P.L. のモナド則



               µX     ⌘T X = idT X

               µX     T ⌘X = idT X
モナド with P.L. のモナド則



               µX     ⌘T X = idT X

               µX     T ⌘X = idT X

              µX   µT X = µX    T µX
モナド with P.L. のモナド則



               µX     ⌘T X = idT X

               µX     T ⌘X = idT X

              µX   µT X = µX    T µX
モナド with P.L. のモナド則



               µX     ⌘T X = idT X

               µX     T ⌘X = idT X

              µX   µT X = µX    T µX
モナド with P.L. のモナド則



                µX    ⌘T X = idT X

                µX    T ⌘X = idT X

              µX   µT X = µX    T µX

             (⌘T X )⌫X   ✓T X ⌧X = id⌧X
モナド with P.L. のモナド則



                µX    ⌘T X = idT X

                µX    T ⌘X = idT X

              µX   µT X = µX     T µX

             (⌘T X )⌫X    ✓T X ⌧X = id⌧X

              (T ⌘X )⌫X   ⌧X ✓X = id⌧X
モナド with P.L. のモナド則



                      µX    ⌘T X = idT X

                      µX   T ⌘X = idT X

                    µX   µT X = µX     T µX

                (⌘T X )⌫X       ✓T X ⌧X = id⌧X

                    (T ⌘X )⌫X   ⌧X ✓X = id⌧X

        (µT X )⌫X     ⌫ T X ⌧X =   (T µX )⌫X     ⌧T 2 X ⌫ X
モナド with P.L. のモナド則



                      µX    ⌘T X = idT X

                      µX   T ⌘X = idT X

                    µX   µT X = µX     T µX

                (⌘T X )⌫X       ✓T X ⌧X = id⌧X

                    (T ⌘X )⌫X   ⌧X ✓X = id⌧X

        (µT X )⌫X     ⌫ T X ⌧X =   (T µX )⌫X     ⌧T 2 X ⌫ X
ここまでに出てきたもの



                     op
                :C        ! Cat




   Kl(T )


            #
 hT, ⌘, ( ) i
Grothendieck構成と
 Predicate Lifting
Grothendieck構成
‣ 添字付圏     から新たな圏  を作る
- 対象は        の組
- 射は              の組
- 合成は
Grothendieck構成
Grothendieck構成
Grothendieck構成
Grothendieck構成
Grothendieck構成
Grothendieck構成
                      op
                 :C        ! Cat
Grothendieck構成
                      op
                 :C        ! Cat
Grothendieck構成
                      op
                 :C        ! Cat
Grothendieck構成
                      op
                 :C        ! Cat
Grothendieck構成
                      op
                 :C        ! Cat
Grothendieck構成
                      op
                 :C        ! Cat
Grothendieck構成
                      op
                 :C        ! Cat
Grothendieck構成
                      op
                 :C        ! Cat
Grothendieck構成
                      op
                 :C        ! Cat
Grothendieck構成
                      op
                 :C        ! Cat
Grothendieck構成
                      op
                 :C        ! Cat
Grothendieck構成
                      op
                 :C        ! Cat
Grothendieck構成
                      op
                 :C        ! Cat
Grothendieck構成
                      op
                 :C        ! Cat
Grothendieck構成
                      op
                 :C        ! Cat
Grothendieck構成
                      op
                 :C        ! Cat
Grothendieck構成
                      op
                 :C        ! Cat
Grothendieck構成
                      op
                 :C        ! Cat
Grothendieck構成
                      op
                 :C        ! Cat
Grothendieck構成
                      op
                 :C        ! Cat
Grothendieck構成に於ける射の合成
Grothendieck構成に於ける射の合成
Grothendieck構成に於ける射の合成
Grothendieck構成に於ける射の合成
Grothendieck構成に於ける射の合成
Grothendieck構成に於ける射の合成
Grothendieck構成に於ける射の合成
Grothendieck構成に於ける射の合成
Grothendieck構成に於ける射の合成
Grothendieck構成に於ける射の合成
Grothendieck構成に於ける射の合成
X with P.L. = X
‣ 函手 with P.L. は   上の函手
                           R     R
 -            から函手 F :         !     が定まる
            F (X, P ) := (F (X), X (P ))
             F (f, p) := (F (f ),   X (p))

‣ モナド with P.L. は     上のモナド
 -                  からモナド    が定まる
                         hT , ⌘, µi
              ⌘ (X,P ) := (⌘X , ✓X,P )
              µ(X,P ) := (µX , ⌫X,P )
“モナド”達の関連

                            op
                       :C        ! Cat

       モノイダル圏                      モノイド対象

        End(C)


        End( )

               R
        End(       )                     hT , ⌘, µi
Kleisli添字付圏
‣ 反変函手
    - splitなモナド with P.L.          の下で
     • 
     •
    - 函手性の証明にsplitnessが要る
‣
    - Kleisli圏 Kl(T ) についての 述語の圏
ここまでに出てきたもの



                     op
                :C        ! Cat


                                  hT , ⌘, µi


   Kl(T )                          Kl(T )


            #
 hT, ⌘, ( ) i
op
               :C        ! Cat


                                 hT , ⌘, µi


  Kl(T )                          Kl(T )


           #
hT, ⌘, ( ) i
op
               :C        ! Cat


                                 hT , ⌘, µi


  Kl(T )                          Kl(T )


           #
hT, ⌘, ( ) i
モナド on Coq


                    op
               :C        ! Cat


                                 hT , ⌘, µi


  Kl(T )                          Kl(T )


           #
hT, ⌘, ( ) i
モナド on Coq


                    op
               :C        ! Cat


                                 hT , ⌘, µi


  Kl(T )                          Kl(T )


           #
hT, ⌘, ( ) i
モナド on Coq     モナド with P.L.


                    op
               :C        ! Cat


                                 hT , ⌘, µi


  Kl(T )                          Kl(T )


           #
hT, ⌘, ( ) i
モナド on Coq     モナド with P.L.


                    op
               :C        ! Cat


                                  hT , ⌘, µi


  Kl(T )                           Kl(T )


           #
hT, ⌘, ( ) i                     hT , ⌘, ( )# i
モナド on Coq     モナド with P.L.


                    op
               :C        ! Cat


                                 =    hT , ⌘, µi


  Kl(T )                               Kl(T )


           #
hT, ⌘, ( ) i                         hT , ⌘, ( )# i
モナド on Coq     モナド with P.L.


                    op
               :C        ! Cat


                                 =   hT , ⌘, µi


  Kl(T )                              Kl(T )


           #
hT, ⌘, ( ) i                     = hT , ⌘, ( )# i
モナド on Coq              モナド with P.L.


                             op
                        :C        ! Cat


                                              =    hT , ⌘, µi


  Kl(T )                                            Kl(T )


           #                         #
hT, ⌘, ( ) i   h(T, ⌧ ), (⌘, ✓), (( ) , [ ? ])i = hT , ⌘, ( )# i
モナド on Coq              モナド with P.L.


                             op
                        :C        ! Cat


                     hT, ⌘, µ, ⌧, ✓, ⌫i       =    hT , ⌘, µi


  Kl(T )                                            Kl(T )


           #                         #
hT, ⌘, ( ) i   h(T, ⌧ ), (⌘, ✓), (( ) , [ ? ])i = hT , ⌘, ( )# i
モナド on Coq           モナド with P.L.


                          op
                     :C        ! Cat


                  hT, ⌘, µ, ⌧, ✓, ⌫i       =   hT , ⌘, µi


  Kl(T )                                        Kl(T )


           #              #
hT, ⌘, ( ) i   hT, ⌘, ( ) , ⌧, ✓, [ ? ]i   = hT , ⌘, ( )# i
モナド on Coq           モナド with P.L.


                          op
                     :C        ! Cat


                  hT, ⌘, µ, ⌧, ✓, ⌫i       =   hT , ⌘, µi


  Kl(T )                                        Kl(T )


           #              #
hT, ⌘, ( ) i   hT, ⌘, ( ) , ⌧, ✓, [ ? ]i   = hT , ⌘, ( )# i
モナド with P.L. on Coq
モナド on Coq            モナド with P.L.


                           op
                      :C        ! Cat


                   hT, ⌘, µ, ⌧, ✓, ⌫i       =   hT , ⌘, µi


  Kl(T )                                         Kl(T )


           #               #
hT, ⌘, ( ) i    hT, ⌘, ( ) , ⌧, ✓, [ ? ]i   = hT , ⌘, ( )# i
モナド with P.L. on Coq
モナド on Coq            モナド with P.L.


                           op
                      :C        ! Cat


                   hT, ⌘, µ, ⌧, ✓, ⌫i       =   hT , ⌘, µi


  Kl(T )                                         Kl(T )


           #               #
hT, ⌘, ( ) i    hT, ⌘, ( ) , ⌧, ✓, [ ? ]i   = hT , ⌘, ( )# i
Kleisli Triples with
Predicate Liftings
Kleisli TripleとP.L.
‣        上のKleisli Triple hT , ⌘, ( )# i
    - T , ⌘ はモナドのそれと同じ
                     #
                         R                     R
    -(    )#
           := {( ) :        ((X, P ), T (Y, Q)) ! (T (X, P ), T (Y, Q
‣ Kleisli Triples with Predicate Liftings
  - hT, ⌘, ( )# , ⌧, ✓, ( )⇧ i
     • ( )⇧ := {( )⇧ : (X)(P, f ⇤ (⌧Y (Q))) ! (T X)(⌧X (P ), (f #
        
‣ splitness
    - モナドとKleisli Tripleの対応から,次のようになる
                             p⇧ = ⌧x (p)
Kleisli TripleとP.L.
‣        上のKleisli Triple hT , ⌘, ( )# i
    - T , ⌘ はモナドのそれと同じ
                    #   ⇧
    -   (f, p)#
             := (f , p )
‣ Kleisli Triples with Predicate Liftings
  - hT, ⌘, ( )# , ⌧, ✓, ( )⇧ i
     • ( )⇧ := {( )⇧ : (X)(P, f ⇤ (⌧Y (Q))) ! (T X)(⌧X (P ), (f #
        
‣ splitness
    - モナドとKleisli Tripleの対応から,次のようになる
                             p⇧ = ⌧x (p)
Kleisli TripleとP.L.
‣       上のKleisli Triple hT , ⌘, ( )# i
       (f, p) : (X, P ) ! (T Y, ⌧Y (Q))
    - T , ⌘ はモナドのそれと同じ
                  #   ⇧
    -   (f, p)#
             := (f , p )
‣ Kleisli Triples with Predicate Liftings
  - hT, ⌘, ( )# , ⌧, ✓, ( )⇧ i
     • ( )⇧ := {( )⇧ : (X)(P, f ⇤ (⌧Y (Q))) ! (T X)(⌧X (P ), (f #
        
‣ splitness
    - モナドとKleisli Tripleの対応から,次のようになる
                           p⇧ = ⌧x (p)
Kleisli TripleとP.L.
‣       上のKleisli Triple hT , ⌘, ( )# i
       (f, p) : (X, P ) ! (T Y, ⌧Y (Q))
    - T , ⌘ はモナドのそれと同じ
                  #   ⇧
    -   (f, p)#
             := (f , p )
‣ Kleisli Triples with Predicate Liftings
               #(f # , p⇧ ) :⇧(T X, ⌧ (P )) ! (T Y, ⌧ (Q))
  - hT, ⌘, ( ) , ⌧, ✓, ( ) i         X               Y
     • ( )⇧ := {( )⇧ : (X)(P, f ⇤ (⌧Y (Q))) ! (T X)(⌧X (P ), (f #
        
‣ splitness
    - モナドとKleisli Tripleの対応から,次のようになる
                           p⇧ = ⌧x (p)
Kleisli TripleとP.L.
‣        上のKleisli Triple hT , ⌘, ( )# i
    - T , ⌘ はモナドのそれと同じ
                    #   ⇧
    -   (f, p)#
             := (f , p )
‣ Kleisli Triples with Predicate Liftings
  - hT, ⌘, ( )# , ⌧, ✓, ( )⇧ i
     • ( )⇧ := {( )⇧ : (X)(P, f ⇤ (⌧Y (Q))) ! (T X)(⌧X (P ), (f #
        
‣ splitness
    - モナドとKleisli Tripleの対応から,次のようになる
                             p⇧ = ⌧x (p)
Kleisli TripleとP.L.
‣        上のKleisli Triple hT , ⌘, ( )# i
    - T , ⌘ はモナドのそれと同じ
                    #   ⇧
    -   (f, p)#
             := (f , p )
‣ Kleisli Triples with Predicate Liftings
  - hT, ⌘, ( )# , ⌧, ✓, ( )⇧ i
     • p : P ! f ⇤ (⌧Y (Q)) 7! p⇧ : ⌧X (P ) ! (f # )⇤ (⌧Y (Q))
        
‣ splitness
    - モナドとKleisli Tripleの対応から,次のようになる
                             p⇧ = ⌧x (p)
Kleisli TripleとP.L.
‣        上のKleisli Triple hT , ⌘, ( )# i
    - T , ⌘ はモナドのそれと同じ


                              ?
                    #   ⇧
    -   (f, p)#
             := (f , p )
‣ Kleisli Triples with Predicate Liftings
  - hT, ⌘, ( )# , ⌧, ✓, ( )⇧ i
     • p : P ! f ⇤ (⌧Y (Q)) 7! p⇧ : ⌧X (P ) ! (f # )⇤ (⌧Y (Q))
        
‣ splitness
    - モナドとKleisli Tripleの対応から,次のようになる
                             p⇧ = ⌧x (p)
Kleisli Triple with P.L. が満たす等式
Kleisli Triple with P.L. が満たす等式



      hT, ⌘, ( )# i
Kleisli Triple with P.L. が満たす等式



      hT, ⌘, ( )# i

         #
     f       ⌘X = f
Kleisli Triple with P.L. が満たす等式



      hT, ⌘, ( )# i

         #
     f       ⌘X = f
       #
      ⌘X     = idT X
Kleisli Triple with P.L. が満たす等式



          hT, ⌘, ( )# i

              #
          f       ⌘X = f
           #
          ⌘X      = idT X
      #       #          #        #
  g       f       = (g       f)
Kleisli Triple with P.L. が満たす等式



          hT, ⌘, ( )# i

              #
          f       ⌘X = f
           #
          ⌘X      = idT X
      #       #          #        #
  g       f       = (g       f)
Kleisli Triple with P.L. が満たす等式



                              hT, ⌘, ( )# , ⌧, ✓, ( )⇧ i

              #
          f       ⌘X = f
           #
          ⌘X      = idT X
      #       #          #        #
  g       f       = (g       f)
Kleisli Triple with P.L. が満たす等式



                              hT, ⌘, ( )# , ⌧, ✓, ( )⇧ i

          f   #
                  ⌘X = f                       (⌘X )(p⇧ ) ✓X,P = p

           #
          ⌘X      = idT X
      #       #          #        #
  g       f       = (g       f)
Kleisli Triple with P.L. が満たす等式



                              hT, ⌘, ( )# , ⌧, ✓, ( )⇧ i

          f   #
                  ⌘X = f                       (⌘X )(p⇧ ) ✓X,P = p

           #                                      ⇧
          ⌘X      = idT X                        ✓X,P   = id⌧X (P )

      #       #          #        #
  g       f       = (g       f)
Kleisli Triple with P.L. が満たす等式



                              hT, ⌘, ( )# , ⌧, ✓, ( )⇧ i

          f   #
                  ⌘X = f                       (⌘X )(p⇧ ) ✓X,P = p

           #                                      ⇧
          ⌘X      = idT X                        ✓X,P   = id⌧X (P )

      #       #          #        #        #    ⇧       ⇧             ⇧   ⇧
  g       f       = (g       f)         (f )(q ) p = ( (f )(q ) p)
Kleisli Triple with P.L. が満たす等式



                              hT, ⌘, ( )# , ⌧, ✓, ( )⇧ i

          f   #
                  ⌘X = f                       (⌘X )(p⇧ ) ✓X,P = p

           #                                      ⇧
          ⌘X      = idT X                        ✓X,P   = id⌧X (P )

      #       #          #        #        #    ⇧       ⇧             ⇧   ⇧
  g       f       = (g       f)         (f )(q ) p = ( (f )(q ) p)
splitness       #
            f       = µT   Tf
splitness                 #
                      f       = µT   Tf


              #   ⇧
            (f , p ) = (µT , ⌫Y,Q ) (T f, ⌧X (p))
splitness                       #
                            f       = µT    Tf


                    #   ⇧
                  (f , p ) = (µT , ⌫Y,Q ) (T f, ⌧X (p))
              #     ⇧
            (f , p ) = (µT          T f, (T f )(⌫Y,Q ) ⌧X (p))
splitness                         #
                              f       = µT    Tf


                    #   ⇧
                  (f , p ) = (µT , ⌫Y,Q ) (T f, ⌧X (p))
              #     ⇧
            (f , p ) = (µT            T f, (T f )(⌫Y,Q ) ⌧X (p))

                        ⇧
                        p =       (T f )(⌫Y,Q ) ⌧X (p)
splitness                         #
                              f       = µT    Tf


                    #   ⇧
                  (f , p ) = (µT , ⌫Y,Q ) (T f, ⌧X (p))
              #     ⇧
            (f , p ) = (µT            T f, (T f )(⌫Y,Q ) ⌧X (p))

                        ⇧
                        p =       (T f )(⌫Y,Q ) ⌧X (p)

                            ⌫Y,Q = id⌧T Y (⌧Y (Q))
splitness                         #
                              f       = µT    Tf


                    #   ⇧
                  (f , p ) = (µT , ⌫Y,Q ) (T f, ⌧X (p))
              #     ⇧
            (f , p ) = (µT            T f, (T f )(⌫Y,Q ) ⌧X (p))



                            ⌫Y,Q = id⌧T Y (⌧Y (Q))
                        ⇧
                        p =       (T f )(⌫Y,Q ) ⌧X (p)
splitness                         #
                              f       = µT    Tf


                    #   ⇧
                  (f , p ) = (µT , ⌫Y,Q ) (T f, ⌧X (p))
              #     ⇧
            (f , p ) = (µT            T f, (T f )(⌫Y,Q ) ⌧X (p))



                            ⌫Y,Q = id⌧T Y (⌧Y (Q))

                                  p⇧ = ⌧X (p)
splitness                       #
                            f       = µT    Tf


                    #   ⇧
                  (f , p ) = (µT , ⌫Y,Q ) (T f, ⌧X (p))
              #     ⇧
            (f , p ) = (µT          T f, (T f )(⌫Y,Q ) ⌧X (p))
splitness                              #
                              µX =   idT X


                    #   ⇧
                  (f , p ) = (µT , ⌫Y,Q ) (T f, ⌧X (p))
              #     ⇧
            (f , p ) = (µT      T f, (T f )(⌫Y,Q ) ⌧X (p))
splitness                             #
                             µX =   idT X


                  (µX , ⌫X,P ) = (idT X , id⌧X (P ) )#
              #   ⇧
            (f , p ) = (µT     T f, (T f )(⌫Y,Q ) ⌧X (p))
splitness                        #
                       µX =    idT X


            (µX , ⌫X,P ) = (idT X , id⌧X (P ) )#
                                 #       ⇧
             (µX , ⌫X,P ) =   (idT X , id⌧X (P ) )
splitness                        #
                       µX =    idT X


            (µX , ⌫X,P ) = (idT X , id⌧X (P ) )#
                                 #       ⇧
             (µX , ⌫X,P ) =   (idT X , id⌧X (P ) )
                                 ⇧
                     ⌫X,P =    id⌧X (P )
splitness                        #
                       µX =    idT X


            (µX , ⌫X,P ) = (idT X , id⌧X (P ) )#
                                 #       ⇧
             (µX , ⌫X,P ) =   (idT X , id⌧X (P ) )
                                 ⇧
                     ⌫X,P =    id⌧X (P )
                         ⇧
                       p = ⌧X (p)
splitness                        #
                       µX =    idT X


            (µX , ⌫X,P ) = (idT X , id⌧X (P ) )#
                                 #       ⇧
             (µX , ⌫X,P ) =   (idT X , id⌧X (P ) )



                         ⇧
                       p = ⌧X (p)

                     ⌫X,P = id⇧X (P )
                              ⌧
splitness                        #
                       µX =    idT X


            (µX , ⌫X,P ) = (idT X , id⌧X (P ) )#
                                 #       ⇧
             (µX , ⌫X,P ) =   (idT X , id⌧X (P ) )



                         ⇧
                       p = ⌧X (p)

                  ⌫X,P = id⌧T X (⌧X (P ))
splitness                        #
                       µX =    idT X


            (µX , ⌫X,P ) = (idT X , id⌧X (P ) )#
                                 #       ⇧
             (µX , ⌫X,P ) =   (idT X , id⌧X (P ) )
splitness                            #
                          µX =     idT X


             (µX , ⌫X,P ) = (idT X , id⌧X (P ) )#
                                     #       ⇧
                 (µX , ⌫X,P ) =   (idT X , id⌧X (P ) )


             ⇧
            p = ⌧X (p) , ⌫X,P = id⌧T X (⌧X (P ))
P.L. on Coq
‣ 添字付圏 について
 - 今回は,Kleisli Triples with Predicate Liftingsの一般的
   な定義・実装を目指したので,反変函手とだけ仮定
 - Moggiの論文に拠れば,述語として用いるなら添字付交
   わり半束+αの性質を持つものとすべき
  • 今後の課題
‣ PredLiftクラス
 - モナドにPredicate Liftingを追加したサブクラス
        ⇧
  • ✓, ( ) はクラスの持つべき性質として現れる
P.L. on Coq
‣ 添字付圏 について
 - 今回は,Kleisli Triples with Predicate Liftingsの一般的
   な定義・実装を目指したので,反変函手とだけ仮定
 - Moggiの論文に拠れば,述語として用いるなら添字付交
   わり半束+αの性質を持つものとすべき
  • 今後の課題            ?
‣ PredLiftクラス
 - モナドにPredicate Liftingを追加したサブクラス
        ⇧
  • ✓, ( ) はクラスの持つべき性質として現れる
P.L. on Coq                                  #                ⇧
                                   hT, ⌘, ( ) , ⌧, ✓, ( ) i

 Class PLMonad `(monad: Monad)(gp: GPred): Type :=
  {
    (* predicate liftings *)
    predlift {A: Set}: gpred A -> gpred (T A);

   (* naturality of predlift *)
   ...

   (* kleisli triple with predlift *)
   ret_pl:
     forall (A: Set)(P: gpred A),
      P --> ret*[(predlift P)];

   bind_pl:
    forall (A B: Set)(f: A -> T B)(P: gpred A)(Q: gpred B),
      (P --> f*[predlift Q]) ->
      ((predlift P) --> (bind f)*[(predlift Q)]);

    (* monad law’s of pl *)
    ...
  }.
P.L. on Coq                                  #                ⇧
                                   hT, ⌘, ( ) , ⌧, ✓, ( ) i

 Class PLMonad `(monad: Monad)(gp: GPred): Type :=
  {
    (* predicate liftings *)
    predlift {A: Set}: gpred A -> gpred (T A);

   (* naturality of predlift *)
   ...

   (* kleisli triple with predlift *)
   ret_pl:
     forall (A: Set)(P: gpred A),
      P --> ret*[(predlift P)];

   bind_pl:
    forall (A B: Set)(f: A -> T B)(P: gpred A)(Q: gpred B),
      (P --> f*[predlift Q]) ->
      ((predlift P) --> (bind f)*[(predlift Q)]);

    (* monad law’s of pl *)
    ...
  }.
P.L. on Coq                                  #                ⇧
                                   hT, ⌘, ( ) , ⌧, ✓, ( ) i

 Class PLMonad `(monad: Monad)(gp: GPred): Type :=
  {
    (* predicate liftings *)
    predlift {A: Set}: gpred A -> gpred (T A);

   (* naturality of predlift *)
   ...

   (* kleisli triple with predlift *)
   ret_pl:
     forall (A: Set)(P: gpred A),
      P --> ret*[(predlift P)];

   bind_pl:
    forall (A B: Set)(f: A -> T B)(P: gpred A)(Q: gpred B),
      (P --> f*[predlift Q]) ->
      ((predlift P) --> (bind f)*[(predlift Q)]);

    (* monad law’s of pl *)
    ...
  }.
P.L. on Coq                                  #                ⇧
                                   hT, ⌘, ( ) , ⌧, ✓, ( ) i

 Class PLMonad `(monad: Monad)(gp: GPred): Type :=
  {
    (* predicate liftings *)
    predlift {A: Set}: gpred A -> gpred (T A);

   (* naturality of predlift *)
   ...

   (* kleisli triple with predlift *)
   ret_pl:
     forall (A: Set)(P: gpred A),
      P --> ret*[(predlift P)];

   bind_pl:
    forall (A B: Set)(f: A -> T B)(P: gpred A)(Q: gpred B),
      (P --> f*[predlift Q]) ->
      ((predlift P) --> (bind f)*[(predlift Q)]);

    (* monad law’s of pl *)
    ...
  }.
P.L. on Coq                                  #                ⇧
                                   hT, ⌘, ( ) , ⌧, ✓, ( ) i

 Class PLMonad `(monad: Monad)(gp: GPred): Type :=
  {
    (* predicate liftings *)
    predlift {A: Set}: gpred A -> gpred (T A);

   (* naturality of predlift *)
   ...

   (* kleisli triple with predlift *)
   ret_pl:
     forall (A: Set)(P: gpred A),
      P --> ret*[(predlift P)];

   bind_pl:
    forall (A B: Set)(f: A -> T B)(P: gpred A)(Q: gpred B),
      (P --> f*[predlift Q]) ->
      ((predlift P) --> (bind f)*[(predlift Q)]);

    (* monad law’s of pl *)
    ...
  }.
P.L. on Coq                                  #                ⇧
                                   hT, ⌘, ( ) , ⌧, ✓, ( ) i

 Class PLMonad `(monad: Monad)(gp: GPred): Type :=
  {
    (* predicate liftings *)
    predlift {A: Set}: gpred A -> gpred (T A);

   (* naturality of predlift *)
   ...

   (* kleisli triple with predlift *)
   ret_pl:
     forall (A: Set)(P: gpred A),
      P --> ret*[(predlift P)];

   bind_pl:
    forall (A B: Set)(f: A -> T B)(P: gpred A)(Q: gpred B),
      (P --> f*[predlift Q]) ->
      ((predlift P) --> (bind f)*[(predlift Q)]);

    (* monad law’s of pl *)
    ...
  }.
P.L. on Coq                                  #                ⇧
                                   hT, ⌘, ( ) , ⌧, ✓, ( ) i

 Class PLMonad `(monad: Monad)(gp: GPred): Type :=
  {
    (* predicate liftings *)
    predlift {A: Set}: gpred A -> gpred (T A);

   (* naturality of predlift *)
   ...

   (* kleisli triple with predlift *)
   ret_pl:
     forall (A: Set)(P: gpred A),
      P --> ret*[(predlift P)];

   bind_pl:
    forall (A B: Set)(f: A -> T B)(P: gpred A)(Q: gpred B),
      (P --> f*[predlift Q]) ->
      ((predlift P) --> (bind f)*[(predlift Q)]);

    (* monad law’s of pl *)
    ...
  }.
P.L. on Coq                                  #                ⇧
                                   hT, ⌘, ( ) , ⌧, ✓, ( ) i

 Class PLMonad `(monad: Monad)(gp: GPred): Type :=
  {
    (* predicate liftings *)
    predlift {A: Set}: gpred A -> gpred (T A);

   (* naturality of predlift *)
   ...

   (* kleisli triple with predlift *)
   ret_pl:
     forall (A: Set)(P: gpred A),
      P --> ret*[(predlift P)];

   bind_pl:
    forall (A B: Set)(f: A -> T B)(P: gpred A)(Q: gpred B),
      (P --> f*[predlift Q]) ->
      ((predlift P) --> (bind f)*[(predlift Q)]);

    (* monad law’s of pl *)
    ...
  }.
P.L. on Coq                                  #                ⇧
                                   hT, ⌘, ( ) , ⌧, ✓, ( ) i

 Class PLMonad `(monad: Monad)(gp: GPred): Type :=
  {
    (* predicate liftings *)
    predlift {A: Set}: gpred A -> gpred (T A);

   (* naturality of predlift *)
   ...

   (* kleisli triple with predlift *)
   ret_pl:
     forall (A: Set)(P: gpred A),
      P --> ret*[(predlift P)];

   bind_pl:
    forall (A B: Set)(f: A -> T B)(P: gpred A)(Q: gpred B),
      (P --> f*[predlift Q]) ->
      ((predlift P) --> (bind f)*[(predlift Q)]);

    (* monad law’s of pl *)
    ...
  }.
splitness on Coq




 Context `(plm: PLMonad).

 (* splitness of monad *)
 Definition ret_pl_splitness :=
   forall (A: Set)(P: gpred A),
    ret*[(predlift P)] --> P.

 Definition bind_pl_splitness :=
  forall (A B: Set)(f: A -> T B)(P: gpred A)(Q: gpred B),
   predlift P --> (bind f)*[(predlift Q)] <->
   predlift P --> predlift (f*[(predlift Q)]).

 Definition is_split := ret_pl_splitness/bind_pl_splitness.
splitness on Coq




 Context `(plm: PLMonad).

 (* splitness of monad *)
 Definition ret_pl_splitness :=
   forall (A: Set)(P: gpred A),
    ret*[(predlift P)] --> P.

 Definition bind_pl_splitness :=
  forall (A B: Set)(f: A -> T B)(P: gpred A)(Q: gpred B),
   predlift P --> (bind f)*[(predlift Q)] <->
   predlift P --> predlift (f*[(predlift Q)]).

 Definition is_split := ret_pl_splitness/bind_pl_splitness.
splitness on Coq




 Context `(plm: PLMonad).

 (* splitness of monad *)
 Definition ret_pl_splitness :=
   forall (A: Set)(P: gpred A),
    ret*[(predlift P)] --> P.

 Definition bind_pl_splitness :=
  forall (A B: Set)(f: A -> T B)(P: gpred A)(Q: gpred B),
   predlift P --> (bind f)*[(predlift Q)] <->
   predlift P --> predlift (f*[(predlift Q)]).

 Definition is_split := ret_pl_splitness/bind_pl_splitness.
splitness on Coq




 Context `(plm: PLMonad).

 (* splitness of monad *)
 Definition ret_pl_splitness :=
   forall (A: Set)(P: gpred A),
    ret*[(predlift P)] --> P.

 Definition bind_pl_splitness :=
  forall (A B: Set)(f: A -> T B)(P: gpred A)(Q: gpred B),
   predlift P --> (bind f)*[(predlift Q)] <->
   predlift P --> predlift (f*[(predlift Q)]).

 Definition is_split := ret_pl_splitness/bind_pl_splitness.
splitness on Coq




 Context `(plm: PLMonad).

 (* splitness of monad *)
 Definition ret_pl_splitness :=
   forall (A: Set)(P: gpred A),
    ret*[(predlift P)] --> P.

 Definition bind_pl_splitness :=
  forall (A B: Set)(f: A -> T B)(P: gpred A)(Q: gpred B),
   predlift P --> (bind f)*[(predlift Q)] <->
   predlift P --> predlift (f*[(predlift Q)]).

 Definition is_split := ret_pl_splitness/bind_pl_splitness.
実装例
‣ 直接ソースコードをお見せします
まとめ
できたこと
‣ Coq上でPredicate Liftingを定義
 - Kleisli Triples with Predicate Liftings
 - Kleisli Tripleのsplitnessの導出と実装
 - 具体例の実装
  • Maybeモナド with P.L. や Stateモナド with P.L.
  • MonadStateに関するホーアトリプル
課題と考察
‣ モナド則やsplitnessのCoqに於ける記述方法
 - 記述する必要が可能性も
 - Proof IrrelevanceとPredicate Lifting
‣ 強モナド,Predicate Lifting,Kleisli Triple
 - これらの間の関連の議論がまだまだ出来ていない
‣ 述語 の取扱について
 - 添字付交わり半束+αに制限するべきか
‣ 実装に至るまでに用いた性質の証明をCoqで
 - 余裕があれば
補足など
モノイダル圏
‣ モノイダル圏
- 圏 ,双函手       ,対象   からなる組
- 結合律
- 単位元律
‣ 対象モノイダル圏
- 積が可換 なモノイダル圏
‣ モノイド対象
- モノイダル圏の対象で, 演算 と 単位元 を与える自然変
  換を伴い,それらが モノイドの公理 を満たすもの
モノイダル圏
‣ モノイダル圏
- 圏 ,双函手       ,対象   からなる組
- 結合律
- 単位元律
     圏Cの自己函手からなる圏はモノイダル圏
‣ 対象モノイダル圏
     C上のモナドとは,この圏のモノイド対象
- 積が可換 なモノイダル圏
‣ モノイド対象
- モノイダル圏の対象で, 演算 と 単位元 を与える自然変
  換を伴い,それらが モノイドの公理 を満たすもの

More Related Content

What's hot

自動定理証明の紹介
自動定理証明の紹介自動定理証明の紹介
自動定理証明の紹介Masahiro Sakai
 
ML: Sparse regression CH.13
 ML: Sparse regression CH.13 ML: Sparse regression CH.13
ML: Sparse regression CH.13Daisuke Yoneoka
 
20120829_TaPL8
20120829_TaPL820120829_TaPL8
20120829_TaPL85th_person
 
パターン認識 05 ロジスティック回帰
パターン認識 05 ロジスティック回帰パターン認識 05 ロジスティック回帰
パターン認識 05 ロジスティック回帰sleipnir002
 
Tapl 5
Tapl 5Tapl 5
Tapl 5rf0444
 
これから Haskell を書くにあたって
これから Haskell を書くにあたってこれから Haskell を書くにあたって
これから Haskell を書くにあたってTsuyoshi Matsudate
 
代数的実数とCADの実装紹介
代数的実数とCADの実装紹介代数的実数とCADの実装紹介
代数的実数とCADの実装紹介Masahiro Sakai
 
PRML ベイズロジスティック回帰
PRML ベイズロジスティック回帰PRML ベイズロジスティック回帰
PRML ベイズロジスティック回帰hagino 3000
 
Deep learning _linear_algebra___probablity___information
Deep learning _linear_algebra___probablity___informationDeep learning _linear_algebra___probablity___information
Deep learning _linear_algebra___probablity___informationtakutori
 
Introduction to the particle filter
Introduction to the particle filterIntroduction to the particle filter
Introduction to the particle filterSatoshi Minakuchi
 
PRML 2.3.9-2.4.1
PRML 2.3.9-2.4.1PRML 2.3.9-2.4.1
PRML 2.3.9-2.4.1marugari
 
mathematical_notation
mathematical_notationmathematical_notation
mathematical_notationKenta Oono
 

What's hot (19)

自動定理証明の紹介
自動定理証明の紹介自動定理証明の紹介
自動定理証明の紹介
 
ML: Sparse regression CH.13
 ML: Sparse regression CH.13 ML: Sparse regression CH.13
ML: Sparse regression CH.13
 
20120829_TaPL8
20120829_TaPL820120829_TaPL8
20120829_TaPL8
 
パターン認識 05 ロジスティック回帰
パターン認識 05 ロジスティック回帰パターン認識 05 ロジスティック回帰
パターン認識 05 ロジスティック回帰
 
Prml 4.3.5
Prml 4.3.5Prml 4.3.5
Prml 4.3.5
 
PRML 第14章
PRML 第14章PRML 第14章
PRML 第14章
 
Sparse models
Sparse modelsSparse models
Sparse models
 
Tapl 5
Tapl 5Tapl 5
Tapl 5
 
Slides ts-1
Slides ts-1Slides ts-1
Slides ts-1
 
C言語講習会3
C言語講習会3C言語講習会3
C言語講習会3
 
これから Haskell を書くにあたって
これから Haskell を書くにあたってこれから Haskell を書くにあたって
これから Haskell を書くにあたって
 
代数的実数とCADの実装紹介
代数的実数とCADの実装紹介代数的実数とCADの実装紹介
代数的実数とCADの実装紹介
 
回帰
回帰回帰
回帰
 
PRML ベイズロジスティック回帰
PRML ベイズロジスティック回帰PRML ベイズロジスティック回帰
PRML ベイズロジスティック回帰
 
Deep learning _linear_algebra___probablity___information
Deep learning _linear_algebra___probablity___informationDeep learning _linear_algebra___probablity___information
Deep learning _linear_algebra___probablity___information
 
Introduction to the particle filter
Introduction to the particle filterIntroduction to the particle filter
Introduction to the particle filter
 
PRML 2.3.9-2.4.1
PRML 2.3.9-2.4.1PRML 2.3.9-2.4.1
PRML 2.3.9-2.4.1
 
JSIAM_2019_9_4
JSIAM_2019_9_4JSIAM_2019_9_4
JSIAM_2019_9_4
 
mathematical_notation
mathematical_notationmathematical_notation
mathematical_notation
 

Similar to Tpp2012 mwpl on_coq

モナドハンズオン前座
モナドハンズオン前座モナドハンズオン前座
モナドハンズオン前座bleis tift
 
PRML 6.1章 カーネル法と双対表現
PRML 6.1章 カーネル法と双対表現PRML 6.1章 カーネル法と双対表現
PRML 6.1章 カーネル法と双対表現hagino 3000
 
topology of musical data
topology of musical datatopology of musical data
topology of musical dataTatsuki SHIMIZU
 
070 統計的推測 母集団と推定
070 統計的推測 母集団と推定070 統計的推測 母集団と推定
070 統計的推測 母集団と推定t2tarumi
 
パターン認識と機械学習6章(カーネル法)
パターン認識と機械学習6章(カーネル法)パターン認識と機械学習6章(カーネル法)
パターン認識と機械学習6章(カーネル法)Yukara Ikemiya
 
パターン認識第9章 学習ベクトル量子化
パターン認識第9章 学習ベクトル量子化パターン認識第9章 学習ベクトル量子化
パターン認識第9章 学習ベクトル量子化Miyoshi Yuya
 
Scala 初心者が米田の補題を Scala で考えてみた
Scala 初心者が米田の補題を Scala で考えてみたScala 初心者が米田の補題を Scala で考えてみた
Scala 初心者が米田の補題を Scala で考えてみたKazuyuki TAKASE
 
Ekmett勉強会発表資料
Ekmett勉強会発表資料Ekmett勉強会発表資料
Ekmett勉強会発表資料時響 逢坂
 
論理と計算のしくみ 5.3 型付きλ計算 (前半)
論理と計算のしくみ 5.3 型付きλ計算 (前半)論理と計算のしくみ 5.3 型付きλ計算 (前半)
論理と計算のしくみ 5.3 型付きλ計算 (前半)Lintaro Ina
 
Deep Learning を実装する
Deep Learning を実装するDeep Learning を実装する
Deep Learning を実装するShuhei Iitsuka
 
Implicit Explicit Scala
Implicit Explicit ScalaImplicit Explicit Scala
Implicit Explicit ScalaKota Mizushima
 
第9回スキル養成講座講義資料
第9回スキル養成講座講義資料第9回スキル養成講座講義資料
第9回スキル養成講座講義資料keiodig
 
代数トポロジー入門
代数トポロジー入門代数トポロジー入門
代数トポロジー入門Tatsuki SHIMIZU
 
introductino to persistent homology and topological data analysis
introductino to persistent homology and topological data analysisintroductino to persistent homology and topological data analysis
introductino to persistent homology and topological data analysisTatsuki SHIMIZU
 

Similar to Tpp2012 mwpl on_coq (20)

Pythonintro
PythonintroPythonintro
Pythonintro
 
モナドハンズオン前座
モナドハンズオン前座モナドハンズオン前座
モナドハンズオン前座
 
NLPforml5
NLPforml5NLPforml5
NLPforml5
 
PRML 6.1章 カーネル法と双対表現
PRML 6.1章 カーネル法と双対表現PRML 6.1章 カーネル法と双対表現
PRML 6.1章 カーネル法と双対表現
 
topology of musical data
topology of musical datatopology of musical data
topology of musical data
 
070 統計的推測 母集団と推定
070 統計的推測 母集団と推定070 統計的推測 母集団と推定
070 統計的推測 母集団と推定
 
パターン認識と機械学習6章(カーネル法)
パターン認識と機械学習6章(カーネル法)パターン認識と機械学習6章(カーネル法)
パターン認識と機械学習6章(カーネル法)
 
TaPL9
TaPL9TaPL9
TaPL9
 
パターン認識第9章 学習ベクトル量子化
パターン認識第9章 学習ベクトル量子化パターン認識第9章 学習ベクトル量子化
パターン認識第9章 学習ベクトル量子化
 
Scala 初心者が米田の補題を Scala で考えてみた
Scala 初心者が米田の補題を Scala で考えてみたScala 初心者が米田の補題を Scala で考えてみた
Scala 初心者が米田の補題を Scala で考えてみた
 
Ekmett勉強会発表資料
Ekmett勉強会発表資料Ekmett勉強会発表資料
Ekmett勉強会発表資料
 
20180728 halide-study
20180728 halide-study20180728 halide-study
20180728 halide-study
 
Haskell Lecture 2
Haskell Lecture 2Haskell Lecture 2
Haskell Lecture 2
 
論理と計算のしくみ 5.3 型付きλ計算 (前半)
論理と計算のしくみ 5.3 型付きλ計算 (前半)論理と計算のしくみ 5.3 型付きλ計算 (前半)
論理と計算のしくみ 5.3 型付きλ計算 (前半)
 
Deep Learning を実装する
Deep Learning を実装するDeep Learning を実装する
Deep Learning を実装する
 
Prml sec6
Prml sec6Prml sec6
Prml sec6
 
Implicit Explicit Scala
Implicit Explicit ScalaImplicit Explicit Scala
Implicit Explicit Scala
 
第9回スキル養成講座講義資料
第9回スキル養成講座講義資料第9回スキル養成講座講義資料
第9回スキル養成講座講義資料
 
代数トポロジー入門
代数トポロジー入門代数トポロジー入門
代数トポロジー入門
 
introductino to persistent homology and topological data analysis
introductino to persistent homology and topological data analysisintroductino to persistent homology and topological data analysis
introductino to persistent homology and topological data analysis
 

Recently uploaded

デジタル・フォレンジックの最新動向(2024年4月27日情洛会総会特別講演スライド)
デジタル・フォレンジックの最新動向(2024年4月27日情洛会総会特別講演スライド)デジタル・フォレンジックの最新動向(2024年4月27日情洛会総会特別講演スライド)
デジタル・フォレンジックの最新動向(2024年4月27日情洛会総会特別講演スライド)UEHARA, Tetsutaro
 
クラウドネイティブなサーバー仮想化基盤 - OpenShift Virtualization.pdf
クラウドネイティブなサーバー仮想化基盤 - OpenShift Virtualization.pdfクラウドネイティブなサーバー仮想化基盤 - OpenShift Virtualization.pdf
クラウドネイティブなサーバー仮想化基盤 - OpenShift Virtualization.pdfFumieNakayama
 
論文紹介:Automated Classification of Model Errors on ImageNet
論文紹介:Automated Classification of Model Errors on ImageNet論文紹介:Automated Classification of Model Errors on ImageNet
論文紹介:Automated Classification of Model Errors on ImageNetToru Tamaki
 
論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...
論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...
論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...Toru Tamaki
 
モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察 ~Text-to-MusicとText-To-ImageかつImage-to-Music...
モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察  ~Text-to-MusicとText-To-ImageかつImage-to-Music...モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察  ~Text-to-MusicとText-To-ImageかつImage-to-Music...
モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察 ~Text-to-MusicとText-To-ImageかつImage-to-Music...博三 太田
 
TSAL operation mechanism and circuit diagram.pdf
TSAL operation mechanism and circuit diagram.pdfTSAL operation mechanism and circuit diagram.pdf
TSAL operation mechanism and circuit diagram.pdftaisei2219
 
SOPを理解する 2024/04/19 の勉強会で発表されたものです
SOPを理解する       2024/04/19 の勉強会で発表されたものですSOPを理解する       2024/04/19 の勉強会で発表されたものです
SOPを理解する 2024/04/19 の勉強会で発表されたものですiPride Co., Ltd.
 
TataPixel: 畳の異方性を利用した切り替え可能なディスプレイの提案
TataPixel: 畳の異方性を利用した切り替え可能なディスプレイの提案TataPixel: 畳の異方性を利用した切り替え可能なディスプレイの提案
TataPixel: 畳の異方性を利用した切り替え可能なディスプレイの提案sugiuralab
 
AWS の OpenShift サービス (ROSA) を使った OpenShift Virtualizationの始め方.pdf
AWS の OpenShift サービス (ROSA) を使った OpenShift Virtualizationの始め方.pdfAWS の OpenShift サービス (ROSA) を使った OpenShift Virtualizationの始め方.pdf
AWS の OpenShift サービス (ROSA) を使った OpenShift Virtualizationの始め方.pdfFumieNakayama
 
【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)
【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)
【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)Hiroki Ichikura
 
CTO, VPoE, テックリードなどリーダーポジションに登用したくなるのはどんな人材か?
CTO, VPoE, テックリードなどリーダーポジションに登用したくなるのはどんな人材か?CTO, VPoE, テックリードなどリーダーポジションに登用したくなるのはどんな人材か?
CTO, VPoE, テックリードなどリーダーポジションに登用したくなるのはどんな人材か?akihisamiyanaga1
 
自分史上一番早い2024振り返り〜コロナ後、仕事は通常ペースに戻ったか〜 by IoT fullstack engineer
自分史上一番早い2024振り返り〜コロナ後、仕事は通常ペースに戻ったか〜 by IoT fullstack engineer自分史上一番早い2024振り返り〜コロナ後、仕事は通常ペースに戻ったか〜 by IoT fullstack engineer
自分史上一番早い2024振り返り〜コロナ後、仕事は通常ペースに戻ったか〜 by IoT fullstack engineerYuki Kikuchi
 
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介Yuma Ohgami
 
論文紹介:Semantic segmentation using Vision Transformers: A survey
論文紹介:Semantic segmentation using Vision Transformers: A survey論文紹介:Semantic segmentation using Vision Transformers: A survey
論文紹介:Semantic segmentation using Vision Transformers: A surveyToru Tamaki
 

Recently uploaded (14)

デジタル・フォレンジックの最新動向(2024年4月27日情洛会総会特別講演スライド)
デジタル・フォレンジックの最新動向(2024年4月27日情洛会総会特別講演スライド)デジタル・フォレンジックの最新動向(2024年4月27日情洛会総会特別講演スライド)
デジタル・フォレンジックの最新動向(2024年4月27日情洛会総会特別講演スライド)
 
クラウドネイティブなサーバー仮想化基盤 - OpenShift Virtualization.pdf
クラウドネイティブなサーバー仮想化基盤 - OpenShift Virtualization.pdfクラウドネイティブなサーバー仮想化基盤 - OpenShift Virtualization.pdf
クラウドネイティブなサーバー仮想化基盤 - OpenShift Virtualization.pdf
 
論文紹介:Automated Classification of Model Errors on ImageNet
論文紹介:Automated Classification of Model Errors on ImageNet論文紹介:Automated Classification of Model Errors on ImageNet
論文紹介:Automated Classification of Model Errors on ImageNet
 
論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...
論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...
論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...
 
モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察 ~Text-to-MusicとText-To-ImageかつImage-to-Music...
モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察  ~Text-to-MusicとText-To-ImageかつImage-to-Music...モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察  ~Text-to-MusicとText-To-ImageかつImage-to-Music...
モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察 ~Text-to-MusicとText-To-ImageかつImage-to-Music...
 
TSAL operation mechanism and circuit diagram.pdf
TSAL operation mechanism and circuit diagram.pdfTSAL operation mechanism and circuit diagram.pdf
TSAL operation mechanism and circuit diagram.pdf
 
SOPを理解する 2024/04/19 の勉強会で発表されたものです
SOPを理解する       2024/04/19 の勉強会で発表されたものですSOPを理解する       2024/04/19 の勉強会で発表されたものです
SOPを理解する 2024/04/19 の勉強会で発表されたものです
 
TataPixel: 畳の異方性を利用した切り替え可能なディスプレイの提案
TataPixel: 畳の異方性を利用した切り替え可能なディスプレイの提案TataPixel: 畳の異方性を利用した切り替え可能なディスプレイの提案
TataPixel: 畳の異方性を利用した切り替え可能なディスプレイの提案
 
AWS の OpenShift サービス (ROSA) を使った OpenShift Virtualizationの始め方.pdf
AWS の OpenShift サービス (ROSA) を使った OpenShift Virtualizationの始め方.pdfAWS の OpenShift サービス (ROSA) を使った OpenShift Virtualizationの始め方.pdf
AWS の OpenShift サービス (ROSA) を使った OpenShift Virtualizationの始め方.pdf
 
【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)
【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)
【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)
 
CTO, VPoE, テックリードなどリーダーポジションに登用したくなるのはどんな人材か?
CTO, VPoE, テックリードなどリーダーポジションに登用したくなるのはどんな人材か?CTO, VPoE, テックリードなどリーダーポジションに登用したくなるのはどんな人材か?
CTO, VPoE, テックリードなどリーダーポジションに登用したくなるのはどんな人材か?
 
自分史上一番早い2024振り返り〜コロナ後、仕事は通常ペースに戻ったか〜 by IoT fullstack engineer
自分史上一番早い2024振り返り〜コロナ後、仕事は通常ペースに戻ったか〜 by IoT fullstack engineer自分史上一番早い2024振り返り〜コロナ後、仕事は通常ペースに戻ったか〜 by IoT fullstack engineer
自分史上一番早い2024振り返り〜コロナ後、仕事は通常ペースに戻ったか〜 by IoT fullstack engineer
 
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介
 
論文紹介:Semantic segmentation using Vision Transformers: A survey
論文紹介:Semantic segmentation using Vision Transformers: A survey論文紹介:Semantic segmentation using Vision Transformers: A survey
論文紹介:Semantic segmentation using Vision Transformers: A survey
 

Tpp2012 mwpl on_coq

  • 1. TPP 2012 at Chiba, Nov 21, 2012 Coq に於ける Monads with Predicate Liftings の実装と考察 千葉大学大学院 理学研究科 須田 啓司
  • 2. 正確には Kleisli Triples with Predicate Liftings の実装です
  • 4. op :C ! Cat hT, ⌘, µ, ⌧, ✓, ⌫i hT , ⌘, µi 各々の道具の中身よりも それらの関係性に重点を置きます Kl(T ) Kl(T ) # # ⇧ hT, ⌘, ( ) i hT, ⌘, ( ) , ⌧, ✓, ( ) i hT , ⌘, ( )# i
  • 7. モナド on Coq ‣ 関数型プログラミングの文脈に於けるモナド - 手続き的にプログラムを記述するための枠組み - 計算効果を統一的に扱うことを可能にする ‣ 型クラスとしてのモナド - 型変換子Tでパラメタライズされた型クラス - モナド則をメンバとして持つ • モナドそのものを推論の対象と出来る - 個々の計算効果はモナドのサブクラスとして記述される • 失敗,状態,非決定性など
  • 8. Record TypeModifier: Type := { tm_modify :> Set -> Set; tm_equivalence {A: Set}: Equivalence (tm_modify A) }. Notation "A =t= B" := (equiv_eq (Equivalence:=tm_equivalence _) A B) (at level 70, no associativity). Reserved Notation "x >>= y" (at level 60, left associativity). Class Monad (T: TypeModifier):= { ret {A: Set}: A -> T A; bind {A B: Set}: (A -> T B) -> T A -> T B where "x >>= y" := (bind y x); unit_left: forall (A B: Set)(f: A -> T B)(a: A), (ret a) >>= f =t= f a; unit_right: forall (A: Set)(m: T A), m >>= ret =t= m; assoc: forall (A B C: Set)(f: A -> T B)(g: B -> T C)(m: T A), (m >>= f >>= g) =t= m >>= (fun x => (f x) >>= g); bind_subst: forall (A B: Set)(m m': T A)(f f': A -> T B), m =t= m' -> (forall a: A, f a =t= f' a) -> m >>= f =t= m' >>= f' }.
  • 9. Record TypeModifier: Type := { tm_modify :> Set -> Set; tm_equivalence {A: Set}: Equivalence (tm_modify A) }. Notation "A =t= B" := (equiv_eq (Equivalence:=tm_equivalence _) A B) (at level 70, no associativity). Reserved Notation "x >>= y" (at level 60, left associativity). Class Monad (T: TypeModifier):= { ret {A: Set}: A -> T A; bind {A B: Set}: (A -> T B) -> T A -> T B where "x >>= y" := (bind y x); unit_left: forall (A B: Set)(f: A -> T B)(a: A), (ret a) >>= f =t= f a; unit_right: forall (A: Set)(m: T A), m >>= ret =t= m; assoc: forall (A B C: Set)(f: A -> T B)(g: B -> T C)(m: T A), (m >>= f >>= g) =t= m >>= (fun x => (f x) >>= g); bind_subst: forall (A B: Set)(m m': T A)(f f': A -> T B), m =t= m' -> (forall a: A, f a =t= f' a) -> m >>= f =t= m' >>= f' }.
  • 10. Record TypeModifier: Type := { tm_modify :> Set -> Set; tm_equivalence {A: Set}: Equivalence (tm_modify A) }. Notation "A =t= B" := (equiv_eq (Equivalence:=tm_equivalence _) A B) (at level 70, no associativity). Reserved Notation "x >>= y" (at level 60, left associativity). Class Monad (T: TypeModifier):= { ret {A: Set}: A -> T A; bind {A B: Set}: (A -> T B) -> T A -> T B where "x >>= y" := (bind y x); unit_left: forall (A B: Set)(f: A -> T B)(a: A), (ret a) >>= f =t= f a; モナド則 unit_right: forall (A: Set)(m: T A), (Kleisli Tripleの3等式) m >>= ret =t= m; assoc: forall (A B C: Set)(f: A -> T B)(g: B -> T C)(m: T A), (m >>= f >>= g) =t= m >>= (fun x => (f x) >>= g); bind_subst: forall (A B: Set)(m m': T A)(f f': A -> T B), m =t= m' -> (forall a: A, f a =t= f' a) -> m >>= f =t= m' >>= f' }.
  • 11. Record TypeModifier: Type := { tm_modify :> Set -> Set; tm_equivalence {A: Set}: Equivalence (tm_modify A) }. Notation "A =t= B" := (equiv_eq (Equivalence:=tm_equivalence _) A B) (at level 70, no associativity). Reserved Notation "x >>= y" (at level 60, left associativity). Class Monad (T: TypeModifier):= { ret {A: Set}: A -> T A; bind {A B: Set}: (A -> T B) -> T A -> T B where "x >>= y" := (bind y x); unit_left: forall (A B: Set)(f: A -> T B)(a: A), (ret a) >>= f =t= f a; モナド則 unit_right: forall (A: Set)(m: T A), (Kleisli Tripleの3等式) m >>= ret =t= m; assoc: forall (A B C: Set)(f: A -> T B)(g: B -> T C)(m: T A), (m >>= f >>= g) =t= m >>= (fun x => (f x) >>= g); bind_subst: forall (A B: Set)(m m': T A)(f f': A -> T B), m =t= m' -> モナド自体も推論の対象 (forall a: A, f a =t= f' a) -> m >>= f =t= m' >>= f' }.
  • 12. Record TypeModifier: Type := { tm_modify :> Set -> Set; tm_equivalence {A: Set}: Equivalence (tm_modify A) }. Notation "A =t= B" := (equiv_eq (Equivalence:=tm_equivalence _) A B) (at level 70, no associativity). Reserved Notation "x >>= y" (at level 60, left associativity). Class Monad (T: TypeModifier):= { ret {A: Set}: A -> T A; bind {A B: Set}: (A -> T B) -> T A -> T B where "x >>= y" := (bind y x); unit_left: forall (A B: Set)(f: A -> T B)(a: A), (ret a) >>= f =t= f a; モナド則 unit_right: forall (A: Set)(m: T A), (Kleisli Tripleの3等式) m >>= ret =t= m; assoc: forall (A B C: Set)(f: A -> T B)(g: B -> T C)(m: T A), (m >>= f >>= g) =t= m >>= (fun x => (f x) >>= g); bind_subst: 等式推論のみ forall (A B: Set)(m m': T A)(f f': A -> T B), m =t= m' -> モナド自体も推論の対象 (forall a: A, f a =t= f' a) -> m >>= f =t= m' >>= f' }.
  • 13. モナドと推論 ‣ 等式推論では - プログラムmと,性質Pを満たすことが 容易にわかる プ ログラムnとの間の等価性を示す. - 間接的な方法 ‣ 述語を使いたい - プログラムmが性質Pを満たす という形の直接的記述 • 特に,bind記法に倣って次のように書きたい. x m; (P x)
  • 14. モナドと述語論理 ‣ (圏論的な)モナドと述語論理に関する研究 - Evaluation Logic. A.M.Pitts. 1990. • 計算型付ラムダ計算を,その上の述語論理へ拡張 - A Semantics for Evaluation Logic. E.Moggi. 1993. • モナドによる計算型付ラムダ計算の意味論を,交わり半束 などを用いて,Evaluation Logicの意味論へと拡張 - Predicate Logic for Functors and Monads. B.Jacobs. 2010 • 述語の一般化とも言える添字付圏と,Predicate Liftingを用 いて,モナドのKleisli圏(や代数)の述語の圏を構成
  • 15. モナドと述語論理 ‣ (圏論的な)モナドと述語論理に関する研究 - Evaluation Logic. A.M.Pitts. 1990. • 計算型付ラムダ計算を,その上の述語論理へ拡張 - A Semantics for Evaluation Logic. E.Moggi. 1993. • モナドによる計算型付ラムダ計算の意味論を,交わり半束 などを用いて,Evaluation Logicの意味論へと拡張 - Predicate Logic for Functors and Monads. B.Jacobs. 2010 • 述語の一般化とも言える添字付圏と,Predicate Liftingを用 いて,モナドのKleisli圏(や代数)の述語の圏を構成
  • 16. モナドと述語論理 ‣ (圏論的な)モナドと述語論理に関する研究 - Evaluation Logic. A.M.Pitts. 1990. • 計算型付ラムダ計算を,その上の述語論理へ拡張 Kleisli Tripleの言葉に言い換え, - A Semantics for Evaluation Logic. E.Moggi. 1993. Coqで実装するのが本発表の目的 • モナドによる計算型付ラムダ計算の意味論を,交わり半束 などを用いて,Evaluation Logicの意味論へと拡張 - Predicate Logic for Functors and Monads. B.Jacobs. 2010 • 述語の一般化とも言える添字付圏と,Predicate Liftingを用 いて,モナドのKleisli圏(や代数)の述語の圏を構成
  • 17. 流れ 圏論的準備 - モナドやKleisli圏,添字付圏など Predicate Liftingの定義 - 函手,モナドとPredicate Lifting Grothendieck構成とPredicate Lifting - 述語の圏 の構成 Kleisli Triples with Predicate Liftings - Coqで実装するための議論と結果
  • 19. Kleisli Triple ‣ 圏C上のKleisli Triple - 次のものからなる三つ組 hT, ⌘, ( )# i • 対象の割り当て • 射の族 • 射の族 - これらは以下の等式を満たす ‣ HaskellやCoqのモナドクラスの実体はこれ
  • 20. モナド ‣ 圏C上のモナド - 自己函手と2つの自然変換からなる三つ組 - 次の図式を可換にする(モナド則) ‣ Kleisli Tripleと同値 - として互いを構成可能
  • 21. Kleisli圏 ‣ モナドTのKleisli圏Kl(T) - 圏C上のモナド    から以下のように構成する • 対象は圏Cの対象と同じ • 射      はCの射 •            の合成射はCの射 • 恒等射は • 圏の公理はモナド則によって与えられる - プログラムはKleisli圏の射として解釈される
  • 22. 添字付圏 ‣ 添字付圏 : C op ! Cat - 例えば ‣ 圏IndCat - 添字付圏全体からなる2-圏 - 射(1-cell) •  - 射の変換(2-cell) • 
  • 23. 添字付圏 ‣ 添字付圏 : C op ! Cat - 例えば ‣ 圏IndCat - 添字付圏全体からなる2-圏 - 射(1-cell) •  - 射の変換(2-cell) • 
  • 24. 添字付圏 ‣ 添字付圏 : C op ! Cat - 例えば ‣ 圏IndCat - 添字付圏全体からなる2-圏 - 射(1-cell) •  - 射の変換(2-cell) • 
  • 25. ここまでに出てきたもの op :C ! Cat Kl(T ) # hT, ⌘, ( ) i
  • 27. 函手とP.L. ‣ Functors with Predicate Liftings - IndCatに於ける自己射       のこと -       をpredicate liftingと呼ぶ • X上の述語     をFX上の述語         に
  • 28. 函手とP.L. ‣ Functors with Predicate Liftings - IndCatに於ける自己射       のこと -       をpredicate liftingと呼ぶ • X上の述語     をFX上の述語         に ( : C op ! Cat) (F, ) /( : C op ! Cat)
  • 29. 函手とP.L. ‣ Functors with Predicate Liftings - IndCatに於ける自己射       のこと -       をpredicate liftingと呼ぶ • X上の述語     をFX上の述語         に op op C C F ✏ +3 C op ✏ ✏ Cat Cat
  • 30. モナドとP.L. ‣ Monads with Predicate Liftings - IndCatの自己射(1-cell)と2つの2-cellからなる三つ組 •  - Predicate Liftingのsplitness • が全て恒等射であるときsplitであるという ✓X,P : P ⇠ = (⌘X )(⌧X (P )) ⌫X,P : ⌧T X (⌧X (P )) ⇠ (µX )(⌧X (P )) =
  • 31. モナドとP.L. ‣ Monads with Predicate Liftings - IndCatの自己射(1-cell)と2つの2-cellからなる三つ組 •  T : C ! C, ⌧ : ) T ⌘ : Id ) T, ✓ = {✓X : Id (X) ) (⌘X )⌧X } µ : T 2 ) T, ⌫ = {⌫X : ⌧T X ⌧X ) (µX )⌧X } - Predicate Liftingのsplitness • が全て恒等射であるときsplitであるという ✓X,P : P ⇠ = (⌘X )(⌧X (P )) ⌫X,P : ⌧T X (⌧X (P )) ⇠ (µX )(⌧X (P )) =
  • 32. モナド with P.L. のモナド則
  • 33. モナド with P.L. のモナド則
  • 34. モナド with P.L. のモナド則 µX ⌘T X = idT X
  • 35. モナド with P.L. のモナド則 µX ⌘T X = idT X µX T ⌘X = idT X
  • 36. モナド with P.L. のモナド則 µX ⌘T X = idT X µX T ⌘X = idT X µX µT X = µX T µX
  • 37. モナド with P.L. のモナド則 µX ⌘T X = idT X µX T ⌘X = idT X µX µT X = µX T µX
  • 38. モナド with P.L. のモナド則 µX ⌘T X = idT X µX T ⌘X = idT X µX µT X = µX T µX
  • 39. モナド with P.L. のモナド則 µX ⌘T X = idT X µX T ⌘X = idT X µX µT X = µX T µX (⌘T X )⌫X ✓T X ⌧X = id⌧X
  • 40. モナド with P.L. のモナド則 µX ⌘T X = idT X µX T ⌘X = idT X µX µT X = µX T µX (⌘T X )⌫X ✓T X ⌧X = id⌧X (T ⌘X )⌫X ⌧X ✓X = id⌧X
  • 41. モナド with P.L. のモナド則 µX ⌘T X = idT X µX T ⌘X = idT X µX µT X = µX T µX (⌘T X )⌫X ✓T X ⌧X = id⌧X (T ⌘X )⌫X ⌧X ✓X = id⌧X (µT X )⌫X ⌫ T X ⌧X = (T µX )⌫X ⌧T 2 X ⌫ X
  • 42. モナド with P.L. のモナド則 µX ⌘T X = idT X µX T ⌘X = idT X µX µT X = µX T µX (⌘T X )⌫X ✓T X ⌧X = id⌧X (T ⌘X )⌫X ⌧X ✓X = id⌧X (µT X )⌫X ⌫ T X ⌧X = (T µX )⌫X ⌧T 2 X ⌫ X
  • 43. ここまでに出てきたもの op :C ! Cat Kl(T ) # hT, ⌘, ( ) i
  • 45. Grothendieck構成 ‣ 添字付圏 から新たな圏  を作る - 対象は の組 - 射は              の組 - 合成は
  • 51. Grothendieck構成 op :C ! Cat
  • 52. Grothendieck構成 op :C ! Cat
  • 53. Grothendieck構成 op :C ! Cat
  • 54. Grothendieck構成 op :C ! Cat
  • 55. Grothendieck構成 op :C ! Cat
  • 56. Grothendieck構成 op :C ! Cat
  • 57. Grothendieck構成 op :C ! Cat
  • 58. Grothendieck構成 op :C ! Cat
  • 59. Grothendieck構成 op :C ! Cat
  • 60. Grothendieck構成 op :C ! Cat
  • 61. Grothendieck構成 op :C ! Cat
  • 62. Grothendieck構成 op :C ! Cat
  • 63. Grothendieck構成 op :C ! Cat
  • 64. Grothendieck構成 op :C ! Cat
  • 65. Grothendieck構成 op :C ! Cat
  • 66. Grothendieck構成 op :C ! Cat
  • 67. Grothendieck構成 op :C ! Cat
  • 68. Grothendieck構成 op :C ! Cat
  • 69. Grothendieck構成 op :C ! Cat
  • 70. Grothendieck構成 op :C ! Cat
  • 82. X with P.L. = X ‣ 函手 with P.L. は 上の函手 R R - から函手 F : ! が定まる F (X, P ) := (F (X), X (P )) F (f, p) := (F (f ), X (p)) ‣ モナド with P.L. は 上のモナド - からモナド    が定まる hT , ⌘, µi ⌘ (X,P ) := (⌘X , ✓X,P ) µ(X,P ) := (µX , ⌫X,P )
  • 83. “モナド”達の関連 op :C ! Cat モノイダル圏 モノイド対象 End(C) End( ) R End( ) hT , ⌘, µi
  • 84. Kleisli添字付圏 ‣ 反変函手 - splitなモナド with P.L. の下で •  • - 函手性の証明にsplitnessが要る ‣ - Kleisli圏 Kl(T ) についての 述語の圏
  • 85. ここまでに出てきたもの op :C ! Cat hT , ⌘, µi Kl(T ) Kl(T ) # hT, ⌘, ( ) i
  • 86. op :C ! Cat hT , ⌘, µi Kl(T ) Kl(T ) # hT, ⌘, ( ) i
  • 87. op :C ! Cat hT , ⌘, µi Kl(T ) Kl(T ) # hT, ⌘, ( ) i
  • 88. モナド on Coq op :C ! Cat hT , ⌘, µi Kl(T ) Kl(T ) # hT, ⌘, ( ) i
  • 89. モナド on Coq op :C ! Cat hT , ⌘, µi Kl(T ) Kl(T ) # hT, ⌘, ( ) i
  • 90. モナド on Coq モナド with P.L. op :C ! Cat hT , ⌘, µi Kl(T ) Kl(T ) # hT, ⌘, ( ) i
  • 91. モナド on Coq モナド with P.L. op :C ! Cat hT , ⌘, µi Kl(T ) Kl(T ) # hT, ⌘, ( ) i hT , ⌘, ( )# i
  • 92. モナド on Coq モナド with P.L. op :C ! Cat = hT , ⌘, µi Kl(T ) Kl(T ) # hT, ⌘, ( ) i hT , ⌘, ( )# i
  • 93. モナド on Coq モナド with P.L. op :C ! Cat = hT , ⌘, µi Kl(T ) Kl(T ) # hT, ⌘, ( ) i = hT , ⌘, ( )# i
  • 94. モナド on Coq モナド with P.L. op :C ! Cat = hT , ⌘, µi Kl(T ) Kl(T ) # # hT, ⌘, ( ) i h(T, ⌧ ), (⌘, ✓), (( ) , [ ? ])i = hT , ⌘, ( )# i
  • 95. モナド on Coq モナド with P.L. op :C ! Cat hT, ⌘, µ, ⌧, ✓, ⌫i = hT , ⌘, µi Kl(T ) Kl(T ) # # hT, ⌘, ( ) i h(T, ⌧ ), (⌘, ✓), (( ) , [ ? ])i = hT , ⌘, ( )# i
  • 96. モナド on Coq モナド with P.L. op :C ! Cat hT, ⌘, µ, ⌧, ✓, ⌫i = hT , ⌘, µi Kl(T ) Kl(T ) # # hT, ⌘, ( ) i hT, ⌘, ( ) , ⌧, ✓, [ ? ]i = hT , ⌘, ( )# i
  • 97. モナド on Coq モナド with P.L. op :C ! Cat hT, ⌘, µ, ⌧, ✓, ⌫i = hT , ⌘, µi Kl(T ) Kl(T ) # # hT, ⌘, ( ) i hT, ⌘, ( ) , ⌧, ✓, [ ? ]i = hT , ⌘, ( )# i
  • 98. モナド with P.L. on Coq モナド on Coq モナド with P.L. op :C ! Cat hT, ⌘, µ, ⌧, ✓, ⌫i = hT , ⌘, µi Kl(T ) Kl(T ) # # hT, ⌘, ( ) i hT, ⌘, ( ) , ⌧, ✓, [ ? ]i = hT , ⌘, ( )# i
  • 99. モナド with P.L. on Coq モナド on Coq モナド with P.L. op :C ! Cat hT, ⌘, µ, ⌧, ✓, ⌫i = hT , ⌘, µi Kl(T ) Kl(T ) # # hT, ⌘, ( ) i hT, ⌘, ( ) , ⌧, ✓, [ ? ]i = hT , ⌘, ( )# i
  • 101. Kleisli TripleとP.L. ‣ 上のKleisli Triple hT , ⌘, ( )# i - T , ⌘ はモナドのそれと同じ # R R -( )# := {( ) : ((X, P ), T (Y, Q)) ! (T (X, P ), T (Y, Q ‣ Kleisli Triples with Predicate Liftings - hT, ⌘, ( )# , ⌧, ✓, ( )⇧ i • ( )⇧ := {( )⇧ : (X)(P, f ⇤ (⌧Y (Q))) ! (T X)(⌧X (P ), (f #   ‣ splitness - モナドとKleisli Tripleの対応から,次のようになる p⇧ = ⌧x (p)
  • 102. Kleisli TripleとP.L. ‣ 上のKleisli Triple hT , ⌘, ( )# i - T , ⌘ はモナドのそれと同じ # ⇧ - (f, p)# := (f , p ) ‣ Kleisli Triples with Predicate Liftings - hT, ⌘, ( )# , ⌧, ✓, ( )⇧ i • ( )⇧ := {( )⇧ : (X)(P, f ⇤ (⌧Y (Q))) ! (T X)(⌧X (P ), (f #   ‣ splitness - モナドとKleisli Tripleの対応から,次のようになる p⇧ = ⌧x (p)
  • 103. Kleisli TripleとP.L. ‣ 上のKleisli Triple hT , ⌘, ( )# i (f, p) : (X, P ) ! (T Y, ⌧Y (Q)) - T , ⌘ はモナドのそれと同じ # ⇧ - (f, p)# := (f , p ) ‣ Kleisli Triples with Predicate Liftings - hT, ⌘, ( )# , ⌧, ✓, ( )⇧ i • ( )⇧ := {( )⇧ : (X)(P, f ⇤ (⌧Y (Q))) ! (T X)(⌧X (P ), (f #   ‣ splitness - モナドとKleisli Tripleの対応から,次のようになる p⇧ = ⌧x (p)
  • 104. Kleisli TripleとP.L. ‣ 上のKleisli Triple hT , ⌘, ( )# i (f, p) : (X, P ) ! (T Y, ⌧Y (Q)) - T , ⌘ はモナドのそれと同じ # ⇧ - (f, p)# := (f , p ) ‣ Kleisli Triples with Predicate Liftings #(f # , p⇧ ) :⇧(T X, ⌧ (P )) ! (T Y, ⌧ (Q)) - hT, ⌘, ( ) , ⌧, ✓, ( ) i X Y • ( )⇧ := {( )⇧ : (X)(P, f ⇤ (⌧Y (Q))) ! (T X)(⌧X (P ), (f #   ‣ splitness - モナドとKleisli Tripleの対応から,次のようになる p⇧ = ⌧x (p)
  • 105. Kleisli TripleとP.L. ‣ 上のKleisli Triple hT , ⌘, ( )# i - T , ⌘ はモナドのそれと同じ # ⇧ - (f, p)# := (f , p ) ‣ Kleisli Triples with Predicate Liftings - hT, ⌘, ( )# , ⌧, ✓, ( )⇧ i • ( )⇧ := {( )⇧ : (X)(P, f ⇤ (⌧Y (Q))) ! (T X)(⌧X (P ), (f #   ‣ splitness - モナドとKleisli Tripleの対応から,次のようになる p⇧ = ⌧x (p)
  • 106. Kleisli TripleとP.L. ‣ 上のKleisli Triple hT , ⌘, ( )# i - T , ⌘ はモナドのそれと同じ # ⇧ - (f, p)# := (f , p ) ‣ Kleisli Triples with Predicate Liftings - hT, ⌘, ( )# , ⌧, ✓, ( )⇧ i • p : P ! f ⇤ (⌧Y (Q)) 7! p⇧ : ⌧X (P ) ! (f # )⇤ (⌧Y (Q))   ‣ splitness - モナドとKleisli Tripleの対応から,次のようになる p⇧ = ⌧x (p)
  • 107. Kleisli TripleとP.L. ‣ 上のKleisli Triple hT , ⌘, ( )# i - T , ⌘ はモナドのそれと同じ ? # ⇧ - (f, p)# := (f , p ) ‣ Kleisli Triples with Predicate Liftings - hT, ⌘, ( )# , ⌧, ✓, ( )⇧ i • p : P ! f ⇤ (⌧Y (Q)) 7! p⇧ : ⌧X (P ) ! (f # )⇤ (⌧Y (Q))   ‣ splitness - モナドとKleisli Tripleの対応から,次のようになる p⇧ = ⌧x (p)
  • 108. Kleisli Triple with P.L. が満たす等式
  • 109. Kleisli Triple with P.L. が満たす等式 hT, ⌘, ( )# i
  • 110. Kleisli Triple with P.L. が満たす等式 hT, ⌘, ( )# i # f ⌘X = f
  • 111. Kleisli Triple with P.L. が満たす等式 hT, ⌘, ( )# i # f ⌘X = f # ⌘X = idT X
  • 112. Kleisli Triple with P.L. が満たす等式 hT, ⌘, ( )# i # f ⌘X = f # ⌘X = idT X # # # # g f = (g f)
  • 113. Kleisli Triple with P.L. が満たす等式 hT, ⌘, ( )# i # f ⌘X = f # ⌘X = idT X # # # # g f = (g f)
  • 114. Kleisli Triple with P.L. が満たす等式 hT, ⌘, ( )# , ⌧, ✓, ( )⇧ i # f ⌘X = f # ⌘X = idT X # # # # g f = (g f)
  • 115. Kleisli Triple with P.L. が満たす等式 hT, ⌘, ( )# , ⌧, ✓, ( )⇧ i f # ⌘X = f (⌘X )(p⇧ ) ✓X,P = p # ⌘X = idT X # # # # g f = (g f)
  • 116. Kleisli Triple with P.L. が満たす等式 hT, ⌘, ( )# , ⌧, ✓, ( )⇧ i f # ⌘X = f (⌘X )(p⇧ ) ✓X,P = p # ⇧ ⌘X = idT X ✓X,P = id⌧X (P ) # # # # g f = (g f)
  • 117. Kleisli Triple with P.L. が満たす等式 hT, ⌘, ( )# , ⌧, ✓, ( )⇧ i f # ⌘X = f (⌘X )(p⇧ ) ✓X,P = p # ⇧ ⌘X = idT X ✓X,P = id⌧X (P ) # # # # # ⇧ ⇧ ⇧ ⇧ g f = (g f) (f )(q ) p = ( (f )(q ) p)
  • 118. Kleisli Triple with P.L. が満たす等式 hT, ⌘, ( )# , ⌧, ✓, ( )⇧ i f # ⌘X = f (⌘X )(p⇧ ) ✓X,P = p # ⇧ ⌘X = idT X ✓X,P = id⌧X (P ) # # # # # ⇧ ⇧ ⇧ ⇧ g f = (g f) (f )(q ) p = ( (f )(q ) p)
  • 119. splitness # f = µT Tf
  • 120. splitness # f = µT Tf # ⇧ (f , p ) = (µT , ⌫Y,Q ) (T f, ⌧X (p))
  • 121. splitness # f = µT Tf # ⇧ (f , p ) = (µT , ⌫Y,Q ) (T f, ⌧X (p)) # ⇧ (f , p ) = (µT T f, (T f )(⌫Y,Q ) ⌧X (p))
  • 122. splitness # f = µT Tf # ⇧ (f , p ) = (µT , ⌫Y,Q ) (T f, ⌧X (p)) # ⇧ (f , p ) = (µT T f, (T f )(⌫Y,Q ) ⌧X (p)) ⇧ p = (T f )(⌫Y,Q ) ⌧X (p)
  • 123. splitness # f = µT Tf # ⇧ (f , p ) = (µT , ⌫Y,Q ) (T f, ⌧X (p)) # ⇧ (f , p ) = (µT T f, (T f )(⌫Y,Q ) ⌧X (p)) ⇧ p = (T f )(⌫Y,Q ) ⌧X (p) ⌫Y,Q = id⌧T Y (⌧Y (Q))
  • 124. splitness # f = µT Tf # ⇧ (f , p ) = (µT , ⌫Y,Q ) (T f, ⌧X (p)) # ⇧ (f , p ) = (µT T f, (T f )(⌫Y,Q ) ⌧X (p)) ⌫Y,Q = id⌧T Y (⌧Y (Q)) ⇧ p = (T f )(⌫Y,Q ) ⌧X (p)
  • 125. splitness # f = µT Tf # ⇧ (f , p ) = (µT , ⌫Y,Q ) (T f, ⌧X (p)) # ⇧ (f , p ) = (µT T f, (T f )(⌫Y,Q ) ⌧X (p)) ⌫Y,Q = id⌧T Y (⌧Y (Q)) p⇧ = ⌧X (p)
  • 126. splitness # f = µT Tf # ⇧ (f , p ) = (µT , ⌫Y,Q ) (T f, ⌧X (p)) # ⇧ (f , p ) = (µT T f, (T f )(⌫Y,Q ) ⌧X (p))
  • 127. splitness # µX = idT X # ⇧ (f , p ) = (µT , ⌫Y,Q ) (T f, ⌧X (p)) # ⇧ (f , p ) = (µT T f, (T f )(⌫Y,Q ) ⌧X (p))
  • 128. splitness # µX = idT X (µX , ⌫X,P ) = (idT X , id⌧X (P ) )# # ⇧ (f , p ) = (µT T f, (T f )(⌫Y,Q ) ⌧X (p))
  • 129. splitness # µX = idT X (µX , ⌫X,P ) = (idT X , id⌧X (P ) )# # ⇧ (µX , ⌫X,P ) = (idT X , id⌧X (P ) )
  • 130. splitness # µX = idT X (µX , ⌫X,P ) = (idT X , id⌧X (P ) )# # ⇧ (µX , ⌫X,P ) = (idT X , id⌧X (P ) ) ⇧ ⌫X,P = id⌧X (P )
  • 131. splitness # µX = idT X (µX , ⌫X,P ) = (idT X , id⌧X (P ) )# # ⇧ (µX , ⌫X,P ) = (idT X , id⌧X (P ) ) ⇧ ⌫X,P = id⌧X (P ) ⇧ p = ⌧X (p)
  • 132. splitness # µX = idT X (µX , ⌫X,P ) = (idT X , id⌧X (P ) )# # ⇧ (µX , ⌫X,P ) = (idT X , id⌧X (P ) ) ⇧ p = ⌧X (p) ⌫X,P = id⇧X (P ) ⌧
  • 133. splitness # µX = idT X (µX , ⌫X,P ) = (idT X , id⌧X (P ) )# # ⇧ (µX , ⌫X,P ) = (idT X , id⌧X (P ) ) ⇧ p = ⌧X (p) ⌫X,P = id⌧T X (⌧X (P ))
  • 134. splitness # µX = idT X (µX , ⌫X,P ) = (idT X , id⌧X (P ) )# # ⇧ (µX , ⌫X,P ) = (idT X , id⌧X (P ) )
  • 135. splitness # µX = idT X (µX , ⌫X,P ) = (idT X , id⌧X (P ) )# # ⇧ (µX , ⌫X,P ) = (idT X , id⌧X (P ) ) ⇧ p = ⌧X (p) , ⌫X,P = id⌧T X (⌧X (P ))
  • 136. P.L. on Coq ‣ 添字付圏 について - 今回は,Kleisli Triples with Predicate Liftingsの一般的 な定義・実装を目指したので,反変函手とだけ仮定 - Moggiの論文に拠れば,述語として用いるなら添字付交 わり半束+αの性質を持つものとすべき • 今後の課題 ‣ PredLiftクラス - モナドにPredicate Liftingを追加したサブクラス ⇧ • ✓, ( ) はクラスの持つべき性質として現れる
  • 137. P.L. on Coq ‣ 添字付圏 について - 今回は,Kleisli Triples with Predicate Liftingsの一般的 な定義・実装を目指したので,反変函手とだけ仮定 - Moggiの論文に拠れば,述語として用いるなら添字付交 わり半束+αの性質を持つものとすべき • 今後の課題 ? ‣ PredLiftクラス - モナドにPredicate Liftingを追加したサブクラス ⇧ • ✓, ( ) はクラスの持つべき性質として現れる
  • 138. P.L. on Coq # ⇧ hT, ⌘, ( ) , ⌧, ✓, ( ) i Class PLMonad `(monad: Monad)(gp: GPred): Type := { (* predicate liftings *) predlift {A: Set}: gpred A -> gpred (T A); (* naturality of predlift *) ... (* kleisli triple with predlift *) ret_pl: forall (A: Set)(P: gpred A), P --> ret*[(predlift P)]; bind_pl: forall (A B: Set)(f: A -> T B)(P: gpred A)(Q: gpred B), (P --> f*[predlift Q]) -> ((predlift P) --> (bind f)*[(predlift Q)]); (* monad law’s of pl *) ... }.
  • 139. P.L. on Coq # ⇧ hT, ⌘, ( ) , ⌧, ✓, ( ) i Class PLMonad `(monad: Monad)(gp: GPred): Type := { (* predicate liftings *) predlift {A: Set}: gpred A -> gpred (T A); (* naturality of predlift *) ... (* kleisli triple with predlift *) ret_pl: forall (A: Set)(P: gpred A), P --> ret*[(predlift P)]; bind_pl: forall (A B: Set)(f: A -> T B)(P: gpred A)(Q: gpred B), (P --> f*[predlift Q]) -> ((predlift P) --> (bind f)*[(predlift Q)]); (* monad law’s of pl *) ... }.
  • 140. P.L. on Coq # ⇧ hT, ⌘, ( ) , ⌧, ✓, ( ) i Class PLMonad `(monad: Monad)(gp: GPred): Type := { (* predicate liftings *) predlift {A: Set}: gpred A -> gpred (T A); (* naturality of predlift *) ... (* kleisli triple with predlift *) ret_pl: forall (A: Set)(P: gpred A), P --> ret*[(predlift P)]; bind_pl: forall (A B: Set)(f: A -> T B)(P: gpred A)(Q: gpred B), (P --> f*[predlift Q]) -> ((predlift P) --> (bind f)*[(predlift Q)]); (* monad law’s of pl *) ... }.
  • 141. P.L. on Coq # ⇧ hT, ⌘, ( ) , ⌧, ✓, ( ) i Class PLMonad `(monad: Monad)(gp: GPred): Type := { (* predicate liftings *) predlift {A: Set}: gpred A -> gpred (T A); (* naturality of predlift *) ... (* kleisli triple with predlift *) ret_pl: forall (A: Set)(P: gpred A), P --> ret*[(predlift P)]; bind_pl: forall (A B: Set)(f: A -> T B)(P: gpred A)(Q: gpred B), (P --> f*[predlift Q]) -> ((predlift P) --> (bind f)*[(predlift Q)]); (* monad law’s of pl *) ... }.
  • 142. P.L. on Coq # ⇧ hT, ⌘, ( ) , ⌧, ✓, ( ) i Class PLMonad `(monad: Monad)(gp: GPred): Type := { (* predicate liftings *) predlift {A: Set}: gpred A -> gpred (T A); (* naturality of predlift *) ... (* kleisli triple with predlift *) ret_pl: forall (A: Set)(P: gpred A), P --> ret*[(predlift P)]; bind_pl: forall (A B: Set)(f: A -> T B)(P: gpred A)(Q: gpred B), (P --> f*[predlift Q]) -> ((predlift P) --> (bind f)*[(predlift Q)]); (* monad law’s of pl *) ... }.
  • 143. P.L. on Coq # ⇧ hT, ⌘, ( ) , ⌧, ✓, ( ) i Class PLMonad `(monad: Monad)(gp: GPred): Type := { (* predicate liftings *) predlift {A: Set}: gpred A -> gpred (T A); (* naturality of predlift *) ... (* kleisli triple with predlift *) ret_pl: forall (A: Set)(P: gpred A), P --> ret*[(predlift P)]; bind_pl: forall (A B: Set)(f: A -> T B)(P: gpred A)(Q: gpred B), (P --> f*[predlift Q]) -> ((predlift P) --> (bind f)*[(predlift Q)]); (* monad law’s of pl *) ... }.
  • 144. P.L. on Coq # ⇧ hT, ⌘, ( ) , ⌧, ✓, ( ) i Class PLMonad `(monad: Monad)(gp: GPred): Type := { (* predicate liftings *) predlift {A: Set}: gpred A -> gpred (T A); (* naturality of predlift *) ... (* kleisli triple with predlift *) ret_pl: forall (A: Set)(P: gpred A), P --> ret*[(predlift P)]; bind_pl: forall (A B: Set)(f: A -> T B)(P: gpred A)(Q: gpred B), (P --> f*[predlift Q]) -> ((predlift P) --> (bind f)*[(predlift Q)]); (* monad law’s of pl *) ... }.
  • 145. P.L. on Coq # ⇧ hT, ⌘, ( ) , ⌧, ✓, ( ) i Class PLMonad `(monad: Monad)(gp: GPred): Type := { (* predicate liftings *) predlift {A: Set}: gpred A -> gpred (T A); (* naturality of predlift *) ... (* kleisli triple with predlift *) ret_pl: forall (A: Set)(P: gpred A), P --> ret*[(predlift P)]; bind_pl: forall (A B: Set)(f: A -> T B)(P: gpred A)(Q: gpred B), (P --> f*[predlift Q]) -> ((predlift P) --> (bind f)*[(predlift Q)]); (* monad law’s of pl *) ... }.
  • 146. P.L. on Coq # ⇧ hT, ⌘, ( ) , ⌧, ✓, ( ) i Class PLMonad `(monad: Monad)(gp: GPred): Type := { (* predicate liftings *) predlift {A: Set}: gpred A -> gpred (T A); (* naturality of predlift *) ... (* kleisli triple with predlift *) ret_pl: forall (A: Set)(P: gpred A), P --> ret*[(predlift P)]; bind_pl: forall (A B: Set)(f: A -> T B)(P: gpred A)(Q: gpred B), (P --> f*[predlift Q]) -> ((predlift P) --> (bind f)*[(predlift Q)]); (* monad law’s of pl *) ... }.
  • 147. splitness on Coq Context `(plm: PLMonad). (* splitness of monad *) Definition ret_pl_splitness := forall (A: Set)(P: gpred A), ret*[(predlift P)] --> P. Definition bind_pl_splitness := forall (A B: Set)(f: A -> T B)(P: gpred A)(Q: gpred B), predlift P --> (bind f)*[(predlift Q)] <-> predlift P --> predlift (f*[(predlift Q)]). Definition is_split := ret_pl_splitness/bind_pl_splitness.
  • 148. splitness on Coq Context `(plm: PLMonad). (* splitness of monad *) Definition ret_pl_splitness := forall (A: Set)(P: gpred A), ret*[(predlift P)] --> P. Definition bind_pl_splitness := forall (A B: Set)(f: A -> T B)(P: gpred A)(Q: gpred B), predlift P --> (bind f)*[(predlift Q)] <-> predlift P --> predlift (f*[(predlift Q)]). Definition is_split := ret_pl_splitness/bind_pl_splitness.
  • 149. splitness on Coq Context `(plm: PLMonad). (* splitness of monad *) Definition ret_pl_splitness := forall (A: Set)(P: gpred A), ret*[(predlift P)] --> P. Definition bind_pl_splitness := forall (A B: Set)(f: A -> T B)(P: gpred A)(Q: gpred B), predlift P --> (bind f)*[(predlift Q)] <-> predlift P --> predlift (f*[(predlift Q)]). Definition is_split := ret_pl_splitness/bind_pl_splitness.
  • 150. splitness on Coq Context `(plm: PLMonad). (* splitness of monad *) Definition ret_pl_splitness := forall (A: Set)(P: gpred A), ret*[(predlift P)] --> P. Definition bind_pl_splitness := forall (A B: Set)(f: A -> T B)(P: gpred A)(Q: gpred B), predlift P --> (bind f)*[(predlift Q)] <-> predlift P --> predlift (f*[(predlift Q)]). Definition is_split := ret_pl_splitness/bind_pl_splitness.
  • 151. splitness on Coq Context `(plm: PLMonad). (* splitness of monad *) Definition ret_pl_splitness := forall (A: Set)(P: gpred A), ret*[(predlift P)] --> P. Definition bind_pl_splitness := forall (A B: Set)(f: A -> T B)(P: gpred A)(Q: gpred B), predlift P --> (bind f)*[(predlift Q)] <-> predlift P --> predlift (f*[(predlift Q)]). Definition is_split := ret_pl_splitness/bind_pl_splitness.
  • 154. できたこと ‣ Coq上でPredicate Liftingを定義 - Kleisli Triples with Predicate Liftings - Kleisli Tripleのsplitnessの導出と実装 - 具体例の実装 • Maybeモナド with P.L. や Stateモナド with P.L. • MonadStateに関するホーアトリプル
  • 155. 課題と考察 ‣ モナド則やsplitnessのCoqに於ける記述方法 - 記述する必要が可能性も - Proof IrrelevanceとPredicate Lifting ‣ 強モナド,Predicate Lifting,Kleisli Triple - これらの間の関連の議論がまだまだ出来ていない ‣ 述語 の取扱について - 添字付交わり半束+αに制限するべきか ‣ 実装に至るまでに用いた性質の証明をCoqで - 余裕があれば
  • 157. モノイダル圏 ‣ モノイダル圏 - 圏 ,双函手       ,対象   からなる組 - 結合律 - 単位元律 ‣ 対象モノイダル圏 - 積が可換 なモノイダル圏 ‣ モノイド対象 - モノイダル圏の対象で, 演算 と 単位元 を与える自然変 換を伴い,それらが モノイドの公理 を満たすもの
  • 158. モノイダル圏 ‣ モノイダル圏 - 圏 ,双函手       ,対象   からなる組 - 結合律 - 単位元律 圏Cの自己函手からなる圏はモノイダル圏 ‣ 対象モノイダル圏 C上のモナドとは,この圏のモノイド対象 - 積が可換 なモノイダル圏 ‣ モノイド対象 - モノイダル圏の対象で, 演算 と 単位元 を与える自然変 換を伴い,それらが モノイドの公理 を満たすもの