Agda
✽ ✩✁✂ ✪✄☎✆✝ ✞❃ ✩✟✠✡❊ ❅ ● ❀
†1
▲ ✷ ☛ ❁
†1
✹❄ ✼☞✌✍✎✏✑✍✒✓
Agda
✔✕✖✺❂✒ ✓✗✘✙✚✦❑✾ ✶✗✔Agda
✒✓ ✛▼✜✢ ✣✤✥✧★✫✬✕✭❏✮✛✯✰ ✱✚✦ ✲✳✴☞✥✵✸✬✕✻✭✿▼❆❇✜❈✘❖❉✚✦
Verification by Agda in script programming
Yoshifumi Yuasa †1 and Yoshiki Kinoshita †1
Agda, a functional programming language, is a powerful proof description langage as well.
In this talk, we introduce basic methods to verify software by Agda, and argue their applica-
tions to script programming.
1.
❋❍ ■ ◆P◗ ❘ ❙❚
Agda
❯❱ ❲❳ ❨❩❬❭❪❫❴ ❵ ❛❜❝❯❞❡❢❣❤
Agda
✐❚ ❥❦❧♠♥♦♣qr♦s t✐✉❛✈✇①❛②③❙④❣❤ ⑤⑥ ⑦❚ ⑧❭❪⑨⑩rChalmers
❶❷ ❸❯❹ ❺❻❼❽ ❾❿➀⑦⑥ ➁❲❣❤
1)
Agda
❚❵➂➃➄st✐➅➁❛➆➇➈➉➊❳➀➋ ➌✇❵➂ ❝❻➍❣❨❩❬❭❪❫❴❵➎⑨➏✐➅➁➈➐❱
➑⑥❣❤ ❫➏ ➒➓➔→❯
Agda
♠♥♦♣→✐➅➁➃➄➅➁✉❛➣↔❯❵➂❢❣➋ ✐❲↕❜❝❾➙➛✐⑦⑥❣
❾➋ ➜➝⑦✐❲ ➞➁➋ ❴❵❙➟❣➠➡❾❥❦❧st❻
➢⑦⑥❣➤➥❙❚➦❲❤
Agda
st❛➧➝➦➨➩➫❯❱❲⑥➭➋ st❛➯➲➳❯➵➸❣❦➺➻➼⑩➏❯➨➩
❢❣⑤✐❾ ❙➟➋ ⑤⑥ ❻➍➽➋ ⑧➾➓♠❬✈✇❻❱❲
⑦⑥❣➍↕➦➚➪ ❧st ❛❴ ❵➈➶ ➹✐➦❣❤
2. Agda
➘➴ ➷➬➮➱✃♠♥♦♣qr♦st✐➅➁❛
Agda
❚Martin-
L¨ of
❧✇➳❻❐ ❒➛❮➫ ➦❧❰⑧Ï→❯➉➞➁❲❣❤Ð❛➙➛Ñ⑦⑥❳❥❦❧st✐❚Ò➦❣ÓÔ➞❳Õ
Ö❚➋ ❥❦❧
“X → Y ”
❯×ØÙ➅❳➋ ÚÛÜ❧“(x : X) → Y (x)”
❾ÝÞ➑⑥➁❲❣ß❙④❣❤ àá❯➨❢❧➨➩❻â♣ã⑨ä❾å➑⑥ ➁æ➽➋ ➌çá
❹ ❛
x
❾è➝↕é❯x
❻“
ÚÛ ➅➁”
ê➀⑦⑥❣➋ ✐❲↕❛❾Ú Û Ü❳❣ë ì❙④❣❤
❧❯➚í✐î➸➁➋ ✉❛❧❯➉➊♠♥♦♣→❯❵➂
†1 (
ï)
ðñòóôõö ÷øNational Institute of Advanced Industrial Science and
Technology (AIST)
data nat : Set where
zero : nat
succ : nat
ùnat
data _==_ (n : nat) : nat
ùSet where
refl : n == n
_+_ : nat
ùnat
ùnat
zero + m = m
succ y + m = succ (y + m)
succ-eq :
{x y : nat}
ùx == y
ùsucc x == succ y
succ-eq refl = refl
assoc :
(n m l : nat)
ù(n + m) + l == n + (m + l)
assoc zero m l = refl
assoc (succ y) m l = succ-eq (assoc y m l)
ú
1 Agda
ûüýþÿ✩✼õ◆ ✩❃▲✐î➸❣
Curry-Howard
❋❧➠ ✶❛✽ ❇ ❙❚➋ ❥ ❦❧❚✹➯➚í➋ÚÛÜ❚➄t❛ ❆③ ●❻✷❁➑⑥❣❤
❖s✁✂ s❛➍↕➦➚í❘❀✁➋ ➄t ❛Õ ③ ●➈➋
⑩⑨ä❧❻➍➽
➌ç❢❣
⑤✐❾ ❙➟
❣❤
⑤⑥ ⑦❻➍➽
Agda
st❚✾ ✸➄t➳✇ ❻✄ ❊ ❢❣➨ ➩ ➫❯➉➊❤Agda
❻➍❣❵➂➃➄❛×☎❯❄1
❻④✆❳❤ ⑤⑤❙❚➋ ✝✞✟✠❦✐✉❛✡ ❛☛ ☞ ❯➌ ç➅➁❲❣❤
Agda
❙❚☛☞❚✌✍✝⑥ ❳♠➓qÏ✪✎❙❚➦➛➋➌ç➑⑥❣✏➟
➈
❛ ❙④❣
❤
⑤❛ ➍
↕➦
➄t➃☞❛➌
ç❚ ⑩⑨ä❧✐➅➁ÝÞ❢❣⑤✐❾✑❲❤ ✉❛✒➋ ✓
❝❛➌ç❯❉✔❛ ❜❝❙✕❲➋✖❈➦❏í❯ÝÞ➅➁➋
[_] : {S : Set}
ùTrans S
ùProp S
ùProp S
[ P ] A s = (t : S)
ùP s t
ùA t
_#_ : {S : Set}
ùTrans S
ùTrans S
ùTrans S
_#_ P Q s u =
✫S ( t
ù(P s t)
✦(Q t u))
seq : {S : Set}
ù{P Q : Trans S}
ù{A : Prop S}
ù(s : S)
ù[ P # Q ] A s
ù[ P ] ([ Q ] A) s
seq s x =
t p u q
ùx u (t , (p , q))
ú
2
▼❆✺✾ ✩✪✁✂✄☎❈ ❁✆✝ë ✞❝❇❯✟➅➁❲❣❤
3.
▲◆✼➘➴◆✠✡☛☞✌✍✎✏✽➱➚➪❧st➦✑❯❴❵❢❣❃✞❻❚➋ ✒☎❛➍↕❻
❉❅➻➦❜❝❚✐⑥➦❲❤ ➠➡st❻➯➲➳❯➵➸❣
❦➺➼⑩➏ ❯
Agda
st❙➨➩➅➋ ♠♥♦♣→❛❄■❲❯⑤❛➼⑩➏✡ ❛➚í ✐➅➁❵➂ ❢❣⑤✐❻➦❣❤
⑤⑤❙❚×☎✐➅➁➋ ✓ ❇✔✵ ➼⑩➏❯❞ ❡❢❣❤
➚➪ ❧st
L
✐✉❛✕✕ ✖✸M
❾➵➸⑦⑥❳✐➟➋
M
❛✗➽❋❣✘✙✓ ❇❛❂✞❯S
✐❢❣❤ ♠♥♦♣→❛✕✕❚
M
❛✓ ❇✔✵❯✚➟✛⑤❢➈❛➦❛❙➋ ✉❛✔ ✵❥✜❯➨❢
S
✡❛★ ✚❦➄t✐➅➁î➸
⑦⑥❣❤ ✝❳➋ ④❣❀ß❛✖✸
M
❻❥❢❣“
➚í
”
❚➋ ✉⑥❯❑❢➍
↕
➦✓❇❛❂✞❯
✢➌❢❣➈
❛ ❙④
❣❤ ➍➞➁➋ ⑤⑥❚
S
✡❛✣ ✚❦➄t✐î➸⑦⑥❣❤⑤❛✤➦➌✥Ù❛✷➋ ♠♥♦♣→
P
✐➚íA
❻➠➅➁➋ ✤✄ ➚í
“[P ] A”
❯✧❛➍↕❻➌➀❣❤[P ] A s ⇐⇒ ∀ △ t, P s t ⇒ A t
⑤⑥❚✬ ♠♥♦♣→
P
❛✕✕✒❻❚✭✞A
❾✮➽ Ô➞➁❲❣✯ ⑤✐❯➨ ❢➚í❙④❣❤❄
2
❻✟➅❳Agda
✰⑨✱❙❚➋ ✡➃❛✤✄➃☞❯➌ç➅➁➋ ♠♥♦♣→❛ ✲✧✕✕❯➨❢❘❀
‘#’
✐❛❥✜❯❵➂➅➁❲❣❤ ⑤❛➚ í
seq
❚➋ ➚ ➪❧st❛❴❵❻✳➤⑥❣➳✇✴①❙④❣✶➻➳✇
(Dynamic
Logic) 3)
❛✹✇❛×➊❙④❣❤ ⑤❛Ð➋ ✻✿❏❊✁●➽❍➅✕ ✕➋ ✂❖➻✕✕❻➊❲ ➁❛✹✇➈④➽➋ ⑤⑥
⑦❯❵➂➅➁♣P✎♣➓Ù➅➁æ➥➭➋ ⑤❛✴①❻❐
➛♠♥♦♣
→❴ ❵❯
Agda
✡❙✕↕⑤✐
❾❙➟
❣❤
4.
◗❘❙☞❚❯➮➷Agda
✒❱❙➄✏❳➼⑩➏Ù❙❚➋ ✕ ✕✖ ✸
M
✁✉❛✓❇❂✞
S
❛❲✴ ➻➦❳❨❚➋ ✭✞➅➈➂➝❙④❣✭❩❚➦❲❤ ✕ ✕✖✸❛❄■❲ ❯❬➝⑦❛❭❪❻➍➽Õ
⑧➾➓♠❬st❚➋ ❵Û❛ ❫♠➓❛⑨❰❜r❨❩❬
❭❪❫✁✖✸❰⑧Ï→☛❛❝❞❯✕↕❡➻❙➐❱➑⑥
❣❤
➠➡✐
➦
❣❰⑧Ï→❛ ✘✙❳❨❚❢➂❙④❣⑤✐
❾✑ ❲❤ ⑤❛➍↕➦
Black Box
❯✹❣❤✞➻❰⑧Ï→❻æ❲ ➁➋ ⑧➾➓♠❬✈✇❾✐❥❻✕➤⑥➁❲❣⑤
✐❯❴❵❢❣❛❚➋ ➼⑩➏ ❴❦❛ ➍↕➦✟✶➎⑨➏ ❙
❚❧♠❙④➽➋
Agda
☛❯❱ ❲❳➌✇❵➂❝❻➍❣❴❵❾♥❱➦❛❙❚➦❲➝✐♦➸
❣❤
♣q
4)
❙❚ ⑤❛ ➍↕➦❰⑧Ï→❛ ❴❵☎✐➅➁➋ ❤
❦❛r⑨s➝⑦➦❣t✉❬✈✇❰⑧Ï→❛✟✶①②➠
✶❯③➞➁❲❣❤ ④r⑨s❻❚ ⑤➊➝❛❨❩❬❭❪❫
❾⑥⑦➅➁æ➽➋ ❤❦❛ ⑧➾➓♠❬❾ ⑤⑥ ⑦❯❝❞➅
➁①②❻➠✈❢❣❤ ④✰r⑧⑨tr❬⑨ r⑨s
,
❨❩❬❭❪❫⑩ ❛✔✵➼⑩➏❯❶➽➋ ✓❇❂✞❷❛❸❹❯
➐❱➅➁➋✉⑥❺⑥❛ t❻✁✹✇❯✄❼✚❱➅➦❾ ⑦➋
➣↔❛❵➂❯✕➞❳❤
➙ ❽❾❿ ➀➁➂
➙ ❽❾❿ ➀➃➄
➅➆➇❿ ➈➉➊
➋➌➍➎
➽➏➈ ➃➄
➙ ❽❾❿ ➀➐➑ ➈➒➄
Apache
ScrEngine ScrEngine
SysLog
SysLog ScrEngine
WebServer ApplicationServer
Tomcat
SysLog
➓❽➔❿→➣↔
Console
5.
↕ ➷ ■❥❦❧♠♥♦♣qr♦st
Agda
✐✉⑥❻➍❣❨❩❬❭❪❫❴❵❝❯❞❡➅❳❤ ✝❳⑧➾➓♠❬✈✇❴❵
➛❛✶ ❱ ❻➊❲➁♦❪ ➅❳❤
➜ ➝ ➞ ➟
1) “The Agda wiki”,
http://wiki.portal.chalmers.se/agda/pmwiki.php.
2) Howard, William A., ”The formulae-as-types
notion of construction”, in Seldin, Jonathan P.;
Hindley, J. Roger, To H.B. Curry: Essays on
Combinatory Logic, Lambda Calculus and For-
malism, Boston, MA: Academic Press, 1980,
pp. 479490
3) Vaughan Pratt, “Semantical Considerations
on Floyd-Hoare Logic”, Proc. 17th Annual
IEEE Symposium on Foundations of Computer
Science, 1976, 109-121.
4)
➠➡➹➢,
➤✷➥➦.
❰⑧Ï→❛✰r⑧⑨tr❬❳✮❻➧➨➅❳
CD
t✉❬✈✇❻æ➥❣①②➠✶❛