SlideShare una empresa de Scribd logo
1 de 45
Descargar para leer sin conexión
Alloy Analyzer



2011   9   23
•          (id:mr_konn / @mr_konn)

                •
                    •
                • Haskell Lover
                • 2010 Summer Intern    PFI


2011   9   23
•   Alloy



                •

                •   Alloy Analyzer
                    http://alloy.mit.edu/alloy4/



2011   9   23
Alloy Analyzer
                •
                    •        →   /



                    •
                    •“   ”


2011   9   23
•       ……

                •
                    •
                    •

2011   9   23
“             ”
                •   Alloy           SAT

                    •
                        •                     (10
                                )

                        •
                •
                    •

2011   9   23
2011   9   23
•
                    •   ,

                •



2011   9   23
•
                    •
                    •
                •
                •
2011   9   23
Alloy
                    enum        {   ,       }
                    enum            {           ,         }
                    abstract sig            {           : one       }

                    abstract sig            {
                           : lone       ,
                           :
                    } {
                      some      => (                =         <=>   .   =   )
                    }



                •
                •
2011   9   23
Alloy                                      (2)
                     one sig     extends            {} {
                                           in
                     }
                     one sig     extends            {} { no         }

                     one sig                          extends           {} {
                           =     <=> ( .        =          =>   .       =      )
                     }

                     pred show {}
                     run show



                •
                •   run : pred

2011   9   23
•
                •

2011   9   23
•
                •

                    •   Yes/No




2011   9   23
Alloy                                 (1)
           module marsandvenus                    abstract sig             {
                                                           :       ,
           enum              {       ,        }
                                                           :   ,
           enum                  {   ,   }
                                                           :       -> one
           enum                  {   ,   }
                                                  } {
                                                    all q :            |
           sig           {
                                                        ((     =       and     =    )
           !         :               -> one
                                                      or (     =       and     =    ))
           }
                                                        <=>        [q] = q.    [this]
                                                  }

                 •
                 •                                     /

2011   9   23
Alloy                        (2)
                •                                   ……
                         one sig          extends    {} {
                               in   and     in
                         }


                    •
                •                                           ……




2011   9   23
pred              (        :   ) {
                    all       :        |
                          .       in       <=> (     .   [   ] =   )
                }
                fact { one             }
                run


                •                 Yes

                •   run



2011   9   23
•
                •

2011   9   23
○   No
                          ○   Yes
                          ×   No
                          ×   Yes

                •
                    YES
2011   9   23
2011   9   23
•
                    •   ……

                    •
                    •
                •            or



2011   9   23
module tour/filesystem

                abstract sig Object {}
                sig Directory extends Object {
                 contents: set Object
                 }
                one sig Root extends Directory {}
                sig File extends Object {}
                sig Alias extends File {to: Object}

                pred show {}
                run show



2011   9   23
……



                •
                    1.   (File)

                    2.

                    3.


2011   9   23
fact FileBelongsSomewhere {
                  all f : File | one d : Directory |
                    f in d.contents
                }

                fact NoRecursiveDirs {
                ! no d : Directory | d in d.contents
                }

                fact RootHasNoSuperDir {
                  no d: Directory | Root in d.contents
                }


                  •   fact :


                  •
                      •                         (      )
2011   9   23
•                                   Directory

                • FileBelongsSomewhere
                fact ObjBelongsSomewhere {
                  all o : Object | one d : Directory | o in d.contents
                }


2011   9   23
……
                •
                • RootHasNoSuperDir
                  ObjBelongsSomewhere

                • all o : Object   all o : Object - Root




2011   9   23
•
                •
                •   ……

2011   9   23
Alloy
                •   Alloy

                •   Object = Directory ⊔ File, Alias ⊆ File

                    •
                •           (   )

                    •   Root        one

                •   contents : Directory          Object

                    •   n                 n

                    •                         1


2011   9   23
•   A+B:A        B

                •   A&B:A        B

                •   A-B:A        B

                •   A in B : A   B   (A ⊆ B)

                    •                 (A∈B)

                •   A = B :A     B



2011   9   23
•   P→Q:              P, Q

                •   A.B :

                    •   A         B



                    •       {(1)} . {1→A, 1→B, 3→B} = {(A), (B)}
                            {1→A, 1→B, 3→B} . {(B)} = {(1), (3)}

                    •

2011   9   23
•   A[B] : B. A

                    •               a.b [c] = c.(a.b)

                    •
                •   ~a :       a

                •   ^a, *a :

                    •   ^{1→2, 2→3} = {1→2, 2→3, 1→3}

                    •   *{1→2, 2→3} = {1→2, 2→3, 1→3, 1→1, 2→2, 3→3}


2011   9   23
•   none :

                    •
                •   univ :

                    •
                •   iden :

                    •   a.iden = a , iden.a = a (forall a)


2011   9   23
•   all x : e | F =    e               x       F

                •   some x : e | F =       x       F

                •   no x : e | F =     x       F

                •   lone x : e | F =               x       F

                •   one x : e | F =            x       F

                    •
2011   9   23
…



                •   /



                •
2011   9   23
fact NoRecursiveDirs {
                ! no d : Directory | d in d.^contents
                }

                fact NoRecursiveAliases {
                ! no a : Alias | a in a.^to
                }



                •
                •
2011   9   23
•



2011   9   23
run
                               pred show {}
                               run show


                • run hoge :      hoge



                 •         show



                 •                       (    )
2011   9   23
pred show {} for 4
                                run show

                •   for n          n

                    •                      n=3

                •
                    •   for 4 but 2 Alias, exactly 1 Directory
                        •   4          2       Alias,        1   Dir

                •
2011   9   23
•       Object   Root

                    •                   …

                •


2011   9   23
assert
                assert TrackableFromRoot {
                  all o : Object | o in Root.^contents
                }

                check TrackableFromRoot




                •                           (               )

                •   check hoge    hoge

                    •   run                          (default: 3)


2011   9   23
•           ……




                • Root Root
                • Object - Root
                          Root.*contents
2011   9   23
assert TrackableFromRoot {
                  all o : Object | o in Root.*contents
                }

                check TrackableFromRoot




                •
                •

2011   9   23
Alloy

                •
                    fact NoRecursiveDirsOrAlias {
                    ! no iden & (^contents + ^to)
                    }
                    fact RootHasNoSuperDir {no contents.Root}
                    fact AllObjBelongSomewhere {
                      all o : Object - Root | some contents.o
                      }
                    assert TrackableFromRoot {
                      Object in Root.*contents
                    }



2011   9   23
• Alloy
                •
                  •
                  • Alloy
                •
2011   9   23
Any Questions?



2011   9   23
2011   9   23

Más contenido relacionado

La actualidad más candente

PyCon2020 Pythonで競プロをしよう! 〜入門者が知っておくべき高速化Tips〜
PyCon2020 Pythonで競プロをしよう! 〜入門者が知っておくべき高速化Tips〜PyCon2020 Pythonで競プロをしよう! 〜入門者が知っておくべき高速化Tips〜
PyCon2020 Pythonで競プロをしよう! 〜入門者が知っておくべき高速化Tips〜
Kosaku Ono
 
Divisor
DivisorDivisor
Divisor
oupc
 
大規模グラフアルゴリズムの最先端
大規模グラフアルゴリズムの最先端大規模グラフアルゴリズムの最先端
大規模グラフアルゴリズムの最先端
Takuya Akiba
 

La actualidad más candente (20)

競プロは社会の役に立たない+ベンチャー企業の話 (NPCA夏合宿OB講演).pdf
競プロは社会の役に立たない+ベンチャー企業の話 (NPCA夏合宿OB講演).pdf競プロは社会の役に立たない+ベンチャー企業の話 (NPCA夏合宿OB講演).pdf
競プロは社会の役に立たない+ベンチャー企業の話 (NPCA夏合宿OB講演).pdf
 
性能測定道 事始め編
性能測定道 事始め編性能測定道 事始め編
性能測定道 事始め編
 
π計算
π計算π計算
π計算
 
キメるClojure
キメるClojureキメるClojure
キメるClojure
 
ラムダ計算入門
ラムダ計算入門ラムダ計算入門
ラムダ計算入門
 
PyCon2020 Pythonで競プロをしよう! 〜入門者が知っておくべき高速化Tips〜
PyCon2020 Pythonで競プロをしよう! 〜入門者が知っておくべき高速化Tips〜PyCon2020 Pythonで競プロをしよう! 〜入門者が知っておくべき高速化Tips〜
PyCon2020 Pythonで競プロをしよう! 〜入門者が知っておくべき高速化Tips〜
 
Ansible specでテストをする話
Ansible specでテストをする話Ansible specでテストをする話
Ansible specでテストをする話
 
「Android案件できます」って言ったら、ヒドい目にあった話
「Android案件できます」って言ったら、ヒドい目にあった話「Android案件できます」って言ったら、ヒドい目にあった話
「Android案件できます」って言ったら、ヒドい目にあった話
 
The Power of Composition
The Power of CompositionThe Power of Composition
The Power of Composition
 
人それぞれの競プロとの向き合い方
人それぞれの競プロとの向き合い方人それぞれの競プロとの向き合い方
人それぞれの競プロとの向き合い方
 
CuPy解説
CuPy解説CuPy解説
CuPy解説
 
「自分のとこでは動くけど…」を無くす devcontainer
「自分のとこでは動くけど…」を無くす devcontainer「自分のとこでは動くけど…」を無くす devcontainer
「自分のとこでは動くけど…」を無くす devcontainer
 
ホモトピー型理論入門
ホモトピー型理論入門ホモトピー型理論入門
ホモトピー型理論入門
 
Divisor
DivisorDivisor
Divisor
 
PEGで構文解析をする
PEGで構文解析をするPEGで構文解析をする
PEGで構文解析をする
 
TLA+についての話
TLA+についての話TLA+についての話
TLA+についての話
 
大規模グラフアルゴリズムの最先端
大規模グラフアルゴリズムの最先端大規模グラフアルゴリズムの最先端
大規模グラフアルゴリズムの最先端
 
データ解析入門
データ解析入門データ解析入門
データ解析入門
 
充足可能性問題のいろいろ
充足可能性問題のいろいろ充足可能性問題のいろいろ
充足可能性問題のいろいろ
 
Re永続データ構造が分からない人のためのスライド
Re永続データ構造が分からない人のためのスライドRe永続データ構造が分からない人のためのスライド
Re永続データ構造が分からない人のためのスライド
 

Más de Hiromi Ishii

Lebesgue 可測性に関する Solovay-Shelah の結果に必要な記述集合論のごく基本的な事項
Lebesgue 可測性に関する Solovay-Shelah の結果に必要な記述集合論のごく基本的な事項Lebesgue 可測性に関する Solovay-Shelah の結果に必要な記述集合論のごく基本的な事項
Lebesgue 可測性に関する Solovay-Shelah の結果に必要な記述集合論のごく基本的な事項
Hiromi Ishii
 

Más de Hiromi Ishii (18)

ものまね鳥を愛でる 結合子論理と計算
ものまね鳥を愛でる 結合子論理と計算ものまね鳥を愛でる 結合子論理と計算
ものまね鳥を愛でる 結合子論理と計算
 
Freer Monads, More Extensible Effects
Freer Monads, More Extensible EffectsFreer Monads, More Extensible Effects
Freer Monads, More Extensible Effects
 
Lebesgue可測性に関するSoloayの定理と実数の集合の正則性
Lebesgue可測性に関するSoloayの定理と実数の集合の正則性Lebesgue可測性に関するSoloayの定理と実数の集合の正則性
Lebesgue可測性に関するSoloayの定理と実数の集合の正則性
 
実数の集合はどこまで可測になれるか?
実数の集合はどこまで可測になれるか?実数の集合はどこまで可測になれるか?
実数の集合はどこまで可測になれるか?
 
(数式の入った)本をつくる
(数式の入った)本をつくる(数式の入った)本をつくる
(数式の入った)本をつくる
 
御清聴ありがとうございました
御清聴ありがとうございました御清聴ありがとうございました
御清聴ありがとうございました
 
Lebesgue 可測性に関する Solovay-Shelah の結果に必要な記述集合論のごく基本的な事項
Lebesgue 可測性に関する Solovay-Shelah の結果に必要な記述集合論のごく基本的な事項Lebesgue 可測性に関する Solovay-Shelah の結果に必要な記述集合論のごく基本的な事項
Lebesgue 可測性に関する Solovay-Shelah の結果に必要な記述集合論のごく基本的な事項
 
技術者が知るべき Gröbner 基底
技術者が知るべき Gröbner 基底技術者が知るべき Gröbner 基底
技術者が知るべき Gröbner 基底
 
数学プログラムを Haskell で書くべき 6 の理由
数学プログラムを Haskell で書くべき 6 の理由数学プログラムを Haskell で書くべき 6 の理由
数学プログラムを Haskell で書くべき 6 の理由
 
Algebraic DP: 動的計画法を書きやすく
Algebraic DP: 動的計画法を書きやすくAlgebraic DP: 動的計画法を書きやすく
Algebraic DP: 動的計画法を書きやすく
 
Yesod でブログエンジンをつくってみた
Yesod でブログエンジンをつくってみたYesod でブログエンジンをつくってみた
Yesod でブログエンジンをつくってみた
 
How wonderful to be (statically) typed 〜型が付くってスバラシイ〜
How wonderful to be (statically) typed 〜型が付くってスバラシイ〜How wonderful to be (statically) typed 〜型が付くってスバラシイ〜
How wonderful to be (statically) typed 〜型が付くってスバラシイ〜
 
Yesodを支える技術
Yesodを支える技術Yesodを支える技術
Yesodを支える技術
 
Invertible-syntax 入門
Invertible-syntax 入門Invertible-syntax 入門
Invertible-syntax 入門
 
最終発表
最終発表最終発表
最終発表
 
Metaprogramming in Haskell
Metaprogramming in HaskellMetaprogramming in Haskell
Metaprogramming in Haskell
 
Template Haskell とか
Template Haskell とかTemplate Haskell とか
Template Haskell とか
 
実践・完全犯罪のつくり方
実践・完全犯罪のつくり方実践・完全犯罪のつくり方
実践・完全犯罪のつくり方
 

Alloy Analyzer のこと

  • 2. (id:mr_konn / @mr_konn) • • • Haskell Lover • 2010 Summer Intern PFI 2011 9 23
  • 3. Alloy • • Alloy Analyzer http://alloy.mit.edu/alloy4/ 2011 9 23
  • 4. Alloy Analyzer • • → / • •“ ” 2011 9 23
  • 5. …… • • • 2011 9 23
  • 6. ” • Alloy SAT • • (10 ) • • • 2011 9 23
  • 7. 2011 9 23
  • 8. • , • 2011 9 23
  • 9. • • • • 2011 9 23
  • 10. Alloy enum { , } enum { , } abstract sig { : one } abstract sig { : lone , : } { some => ( = <=> . = ) } • • 2011 9 23
  • 11. Alloy (2) one sig extends {} { in } one sig extends {} { no } one sig extends {} { = <=> ( . = => . = ) } pred show {} run show • • run : pred 2011 9 23
  • 12. • 2011 9 23
  • 13. • • Yes/No 2011 9 23
  • 14. Alloy (1) module marsandvenus abstract sig { : , enum { , } : , enum { , } : -> one enum { , } } { all q : | sig { (( = and = ) ! : -> one or ( = and = )) } <=> [q] = q. [this] } • • / 2011 9 23
  • 15. Alloy (2) • …… one sig extends {} { in and in } • • …… 2011 9 23
  • 16. pred ( : ) { all : | . in <=> ( . [ ] = ) } fact { one } run • Yes • run 2011 9 23
  • 17. • 2011 9 23
  • 18. No ○ Yes × No × Yes • YES 2011 9 23
  • 19. 2011 9 23
  • 20. • …… • • • or 2011 9 23
  • 21. module tour/filesystem abstract sig Object {} sig Directory extends Object { contents: set Object } one sig Root extends Directory {} sig File extends Object {} sig Alias extends File {to: Object} pred show {} run show 2011 9 23
  • 22. …… • 1. (File) 2. 3. 2011 9 23
  • 23. fact FileBelongsSomewhere { all f : File | one d : Directory | f in d.contents } fact NoRecursiveDirs { ! no d : Directory | d in d.contents } fact RootHasNoSuperDir { no d: Directory | Root in d.contents } • fact : • • ( ) 2011 9 23
  • 24. Directory • FileBelongsSomewhere fact ObjBelongsSomewhere { all o : Object | one d : Directory | o in d.contents } 2011 9 23
  • 25. …… • • RootHasNoSuperDir ObjBelongsSomewhere • all o : Object all o : Object - Root 2011 9 23
  • 26. • • …… 2011 9 23
  • 27. Alloy • Alloy • Object = Directory ⊔ File, Alias ⊆ File • • ( ) • Root one • contents : Directory Object • n n • 1 2011 9 23
  • 28. A+B:A B • A&B:A B • A-B:A B • A in B : A B (A ⊆ B) • (A∈B) • A = B :A B 2011 9 23
  • 29. P→Q: P, Q • A.B : • A B • {(1)} . {1→A, 1→B, 3→B} = {(A), (B)} {1→A, 1→B, 3→B} . {(B)} = {(1), (3)} • 2011 9 23
  • 30. A[B] : B. A • a.b [c] = c.(a.b) • • ~a : a • ^a, *a : • ^{1→2, 2→3} = {1→2, 2→3, 1→3} • *{1→2, 2→3} = {1→2, 2→3, 1→3, 1→1, 2→2, 3→3} 2011 9 23
  • 31. none : • • univ : • • iden : • a.iden = a , iden.a = a (forall a) 2011 9 23
  • 32. all x : e | F = e x F • some x : e | F = x F • no x : e | F = x F • lone x : e | F = x F • one x : e | F = x F • 2011 9 23
  • 33. • / • 2011 9 23
  • 34. fact NoRecursiveDirs { ! no d : Directory | d in d.^contents } fact NoRecursiveAliases { ! no a : Alias | a in a.^to } • • 2011 9 23
  • 35. • 2011 9 23
  • 36. run pred show {} run show • run hoge : hoge • show • ( ) 2011 9 23
  • 37. pred show {} for 4 run show • for n n • n=3 • • for 4 but 2 Alias, exactly 1 Directory • 4 2 Alias, 1 Dir • 2011 9 23
  • 38. Object Root • … • 2011 9 23
  • 39. assert assert TrackableFromRoot { all o : Object | o in Root.^contents } check TrackableFromRoot • ( ) • check hoge hoge • run (default: 3) 2011 9 23
  • 40. …… • Root Root • Object - Root Root.*contents 2011 9 23
  • 41. assert TrackableFromRoot { all o : Object | o in Root.*contents } check TrackableFromRoot • • 2011 9 23
  • 42. Alloy • fact NoRecursiveDirsOrAlias { ! no iden & (^contents + ^to) } fact RootHasNoSuperDir {no contents.Root} fact AllObjBelongSomewhere { all o : Object - Root | some contents.o } assert TrackableFromRoot { Object in Root.*contents } 2011 9 23
  • 43. • Alloy • • • Alloy • 2011 9 23
  • 45. 2011 9 23