Alloyã§ç´ç©ãèãã
ååã®ç¶ãã§ããæ£ç¢ºã«ã¯ãååã®ç¶ãã®å¾ã®æªå±±ããã®ããã°è¨äºã«å¯¾ããæ´ãªããåãã®æãã§ãã
ä¸é£ã®è¨äºãèªãã§ããããèãã¦ãããã¡ãå®ã¯ç´åã ãã§ãªãç´ç©ãåé¡ã ã¨ãããã¨ããããã¾ããï½
ã¨ãããã¨ã§ãååã¨ã»ã¼åãããªã§ç´ç©ãèãã¦ã¿ã¾ããä»åã使ã£ãAlloyè¨è¿°å
¨æã¯Gistã«è²¼ãã¾ããã
ãã¨ãä¸è¨æªå±±ããã®è¨äºã®ãé¢ä¿åã観å¯ãã¦ã¿ãã以éãé©æå¼ç¨ãã¾ããAlloyã¯é¢ä¿ããã¼ã¹ã«ããè¨èªãªã®ã§ãé¢ä¿åã¨ã¯ç¸æ§ãã¨ã¦ãããã®ã§ãã
ãè³ç«ã¦
ãã£ãåé¡ããã¨ã¯æ¸ãããã®ã®ãç´ç©ã¯ç´åã¨éããAlloyã«ã¯ã¡ããã¨è¨èªæ©è½ã¨ãã¦ããã¾ããéåA ã«å¯¾ã㦠A->A ã¨æ¸ãã¾ãã
ãªãã§ç´ç©ãªã®ã«é¢æ°åã¿ãããªæ¸ãæ¹ããã®ï¼ã¨ããæ¹ã«ã¯こちらããé¢ä¿åã§ã¯ï¼ç¿»ã£ã¦Alloyãï¼éåã®ç´ç©ã¯åªã¨ãé¢æ°ï¼é¢ä¿ã ãã©ï¼ã¨ã»ã¼åä¸è¦ã§ããããã§ãã
ã¨ãããã¨ã§ããã®Alloyã®ç´ç©ãè°è«ã®å¯¾è±¡ã¨ãã¦æ±ãã¾ããæªå±±ããã®è¨äºã«åãããã¨ããã³ã½ã«ç©ã¨å¼ã¶ã¹ãã§ãããã
åä½å ï¼åä½å¯¾è±¡ï¼
é¢ä¿åRelã§ã¯ããã ã»ãã Rel(A, {0, 1}) ã¯Aã®ããéåã«ã¯ãªãã¾ãããRel(A, {0}) ãAã®ããéåãªã®ã§ãã{0}ã¯åå éå1ã§ãã1ã¯ãé¢ä¿åã«ããã¦ã¯å§å¯¾è±¡ã§ãçµå¯¾è±¡ã§ãããã¾ããï¼å§å¯¾è±¡ï¼çµå¯¾è±¡ï¼ç©ºéåã§ãï¼ã1ã¯ããã³ã½ã«ç©ï¼éåã®ç´ç©ã§ããï¼ã®åä½å¯¾è±¡ã¨ãã¦ç¹å¾´ä»ãããã¾ãã
ã ããããªã®ã§ãåå
éåãæã£ã¦ãã¾ãããã
Alloyã«ã¯ç¹å¥ç¹å®ã®åå
éåãããããã§ã¯ãªãã®ã§ã1ãããããã¾ããã¨è¨ã£ã¦ã1è¡ã§çµäºã§ããã
one sig Unit {}
åé ã®oneã§ãå¿ ã1åã ãåå¨ãããããªãã¡åå éåã§ããã¨ãã宣è¨ããã¦ããã¾ãã
ã§ãããããã³ã½ã«ç©ã®åä½å¯¾è±¡ã«ãªã£ã¦ããã¨ã確ããã¦ã¿ã¾ãã
â¦â¦ã¨ãã£ã¦ããåç´ãããªããã§ããããããè¦ã¯ã Unit->A ãªãã A->Unit ã Aã¨ååã«ãªã£ã¦ããã£ã¦è¨ãã°ãããã§ããã©ã
ååã§ãããã¨ã®è¨¼æã£ã¦Alloyã§æ¸ãã¥ããâ¦â¦*1
ã¦ãªããã§ããéåã®ãµã¤ãºãçãããã£ã¦ãããéæ¥çãªå½¢ã§ç¢ºèªãããã¨ã«ãã¾ãã
ã¨ãããã¨ã§ã以ä¸ã®ã¢ãµã¼ã·ã§ã³ããåä¾åºãªãã¨æãã¾ãã
check { all a: set univ { #(Unit -> a) = #a #(a -> Unit) = #a } }
対è§ãä½å¯¾è§
対è§ã§ããããããªæãã§ãç´åã®æã¨ã»ã¨ãã©æè¦ã¯åãã§ãã
fun diagP (a: univ): univ -> univ { a -> a }
é©å½ãªéåAã«å¯¾ãã¦ãA->Aãä½ã£ã¦è¿ãã¦ããã ãã§ãã
ä¸æ¹ä½å¯¾è§ã§ããããªããããã®ã§ã
è«çç©â§ã¯ãp, q:Aâ1 ã«å¯¾ãã¦ãδA;(pÃq);Ï ã¨å®ç¾©ãããÏ:1Ã1â1 ã¯ããã³ã½ã«ç©ã®åä½æ³åã«ä¼´ãèªç¶ååã
ã«ããÏ:1Ã1â1 ï¼ããã¾ã§ã®æ¸ãæ¹ã«æ²¿ãã°ãÏ:(Unit->Unit)->Unitï¼ããããã¾ãããããããªæãã§ãã
fun ro (r: Unit -> Unit): Unit { Unit.r }
rã®é ããUnitã¨çµåãã¦ãr: Unit->Unitã®å¾ãå´ã®æåï¼ç¬¬äºæåï¼ã ããåãåºãã¦è¿ãã¾ãã
ãï¼ç¬¬ä¸æåã¯è¦ããªãã®ï¼ããã§ããã®ï¼ï¼ ã¨ãæãã«ãªãããããã¾ãããâ¦â¦ä¸è¬çã«ã¯ãã¡ããããã¾ããããããAlloyã®ç¢å°åç´ç©ã使ãåã«ã¯ãããã§æ§ãã¾ããããã®çç±ã¯å¾ã§è¿°ã¹ã¾ãã
ã§ããã£ãããªã®ã§ãä¸è¨ã®è«çç© Î´A;(pÃq);Ï ãä½ã£ã¦ãã¾ãã¾ãããã ã¾ã㯠δA 㨠(pÃq) ãçµåããããã«ã次ã®ãããªé¢æ°ããããã¾ãã
fun joinL (a: univ->univ, r: (univ->Unit)->(univ->Unit)): Unit->Unit { (a.univ).(r.univ.univ) -> (univ.a).(univ.(univ.r)) }
aã®ç¬¬ä¸æåã¨rã®ç¬¬ä¸æåã第äºæåã¨ç¬¬äºæåãçµåãã¦ãæ¹ã㦠-> ã§ã¤ãªããªããã¾ããããããç´åã®ã¨ãã«èããçµåã¨ãåºæ¬çãªçå±ã¯åãã§ãã
以ä¸ã® diagPï¼Î´Aï¼ã¨joinLï¼çµåå ; ï¼ãroï¼Ïï¼ãã¤ãªãã§ããã£ãã®è«çç©ã®å®ç¾©ãæ¸ãä¸ãã¾ãã
fun prodL (f,g: univ -> Unit): univ -> Unit { {x: univ, u: Unit | u = x.diagP.joinL [f -> g].ro } }
ãããã¦ãè«çç© f ⧠g ãå®ç¾©ã§ãããã§ããã©ãã
ããã£ã¦çµå±ããã£ã±ããAlloyã§ããã¨ããã®
f & g
ã¨åããªãã§ããããå®éã以ä¸ã®ã¢ãµã¼ã·ã§ã³ã¯åä¾åºãªãã§ãã
equiv_product: check { all f, g: univ -> Unit | prodL[f, g] = f & g }
ã¨ãããã¨ã§ãç´åã®æã¨ãªããã»ã¼åãã§ãããã¡ããã¡ããã
ã¡ãªã¿ã«ã以前紹介ããドメイン付きクリーネ代数のAlloyモデルã§ãããå½é¡ãPropã®ã¹ãéåï¼set Propï¼ã§ä¸ããè«çç©ã¯ãã®éã®éåç© & ã§æ¸ãã¦ã¾ããããã®è¾ºã¨ããã¤ãªãã£ãæãï¼
ç´ç©ã«ããããããã
ã§ãä¸è¨ ro ã®å®ç¾©ããªãã§ãããªããå æ¸ã§ããã®ããã¨ããã話ã§ããã
å®ã¯ãã²ã¨ãã¡ã«ãç´ç©ãã¨è¨ã£ã¦ããããã§ã¼ãªå·®ã§ããã¤ã種é¡ãããã®ã§ããããã§ãAlloyã®ç¢å°åç´ç©ã使ãåã«ã¯ããã§æ§ããªãããªãã¦ããã§ã¼ãªè¡¨ç¾ãããã®ã§ãã
ro ã®å¼æ° r: Unit -> Unit ï¼ï¼UnitÃUnitï¼ã§ãããå
·ä½çã«ä½ç¨®é¡ã®å¤ãããããããã¾ãï¼
Unitãåå
éåã ã£ãã®ã§ãUnitåã®å¼æ°ã«ã¯ããã ã1è¦ç´ ããå
¥ãã¾ããããªã®ã§UnitÃUnitãªãã第ä¸æåã第äºæåããããã«ããããï¼Unitãã®ãã®ï¼ãããªããï¼ç©ºéå noneï¼ãã®2æãããªãããã£ã¦ r 㯠4種é¡ã
â¦â¦ã¨è¦ãããã¦ãå®ã¯Alloyã®å ´åã2種é¡ããããã¾ãããAlloyã®ç´ç©ã¯strictãªç´ç©ï¼ã¹ããã·ã¥ç´ç©ã¨ãããã¾ãï¼ã«ãªã£ã¦ãã¦ãçæ¹ã®æåã空éåãªãããã ã¡ã«å
¨ä½ã空éåã«ãªãã¾ã*2ããªã®ã§ã第ä¸æåã第äºæåã¨ããããããã両æ¹ã¨ããªãã£ããã¨ã«ãªããã®2æãªã®ã§ãã
ä¸æ¹ãä¸è¬çãªéåã®ç´ç©ãéååã®ç´ç©ã¯strictã§ã¯ãªãããªã®ã§çæ¹ã空éåã¨ããã ãã§å
¨ä½ã空éåã¨å®å
¨ã«ã¤ã³ã¼ã«ã«ã¯ãªãã¾ããï¼ååã«ã¯ãªããã©ï¼ãã¨ãããã¨ã§ãããã§ã¼ã«éããã§ããã
ãªã®ã§ roã¯ãæ¬å½ãªãã第ä¸æåã¨ç¬¬äºæåãã¨ãã«ç©ºã§ãªãå ´åã«åå
éåãè¿ããããã§ãªããã°ç©ºéåãè¿ããã¨æ¸ãã¹ããªãã§ãããããç¾å®çã«ã¯ãã©ã£ã¡ã空ã§ãªããã©ã£ã¡ã空ããããé¸æè¢ããªãã®ã§ãçæ¹ã ãåç
§ãããã¨ããä¸ã®å®ç¾©ã§æãç«ã£ã¦ãããã§ãã
Alloyããªããã£ãã®ç´ç© -> ãããªãã¦ãæ°ãã«ä¸è¬çãªç´ç©ãèµ·ããã°ããã£ãã®ããããã¾ããããé¢åãããã£ãã®ã§ãããã¯ãã