annotate paper/tex/hoare.tex @ 11:1cde48f23236

FIN proto
author soto <soto@cr.ie.u-ryukyu.ac.jp>
date Mon, 15 Feb 2021 03:51:35 +0900
parents bf1f62556b81
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
959f4b34d6f4 add final thesis
soto
parents:
diff changeset
1 \chapter{Hoare Logic}
959f4b34d6f4 add final thesis
soto
parents:
diff changeset
2
959f4b34d6f4 add final thesis
soto
parents:
diff changeset
3 \section{Hoare Logic}
959f4b34d6f4 add final thesis
soto
parents:
diff changeset
4 Hoare Logic\ref{hoare} とは C.A.R Hoare、
959f4b34d6f4 add final thesis
soto
parents:
diff changeset
5 R.W Floyd が考案したプログラムの検証の手法である。
959f4b34d6f4 add final thesis
soto
parents:
diff changeset
6 これは、「プログラムの事前条件(P)が成立しているとき、コマンド(C)実行して停止すると事後条件(Q)が成り立つ」
959f4b34d6f4 add final thesis
soto
parents:
diff changeset
7 というもので、CbCの実行を継続するという性質に非常に相性が良い。
959f4b34d6f4 add final thesis
soto
parents:
diff changeset
8 Hoare Logic を表記すると以下のようになる。
959f4b34d6f4 add final thesis
soto
parents:
diff changeset
9 $$ \{P\}\ C \ \{Q\} $$
959f4b34d6f4 add final thesis
soto
parents:
diff changeset
10 この3つ組は Hoare Triple と呼ばれる。
959f4b34d6f4 add final thesis
soto
parents:
diff changeset
11
959f4b34d6f4 add final thesis
soto
parents:
diff changeset
12 Hoare Triple の事後条件を受け取り、
959f4b34d6f4 add final thesis
soto
parents:
diff changeset
13 異なる条件を返す別の Hoare Triple を繋げることでプログラムを記述していく。
959f4b34d6f4 add final thesis
soto
parents:
diff changeset
14
959f4b34d6f4 add final thesis
soto
parents:
diff changeset
15 Hoare Logic の検証では、
959f4b34d6f4 add final thesis
soto
parents:
diff changeset
16 「条件がすべて正しく接続されている」かつ「コマンドが停止する」ことが必要である。
959f4b34d6f4 add final thesis
soto
parents:
diff changeset
17 これらを満たし、
959f4b34d6f4 add final thesis
soto
parents:
diff changeset
18 事前条件から事後条件を導けることを検証することで Hoare Logic の健全性を示すことができる。
959f4b34d6f4 add final thesis
soto
parents:
diff changeset
19
4
bf1f62556b81 add while_test_init_imple
soto
parents: 3
diff changeset
20 \section{Hoare Logic による Code Gear の検証手法 }
3
959f4b34d6f4 add final thesis
soto
parents:
diff changeset
21
959f4b34d6f4 add final thesis
soto
parents:
diff changeset
22 \figref{hoare}が agda にて Hoare Logic を用いて Code Gear を検証する際の流れになる。
959f4b34d6f4 add final thesis
soto
parents:
diff changeset
23 input DataGear が Hoare Logic上の Pre Condition(事前条件)となり、
959f4b34d6f4 add final thesis
soto
parents:
diff changeset
24 output DataGear が Post Conditionとなる。
959f4b34d6f4 add final thesis
soto
parents:
diff changeset
25 各DataGear が Pre / Post Condition を満たしているかの検証は、
959f4b34d6f4 add final thesis
soto
parents:
diff changeset
26 各 Condition を Meta DataGear で定義し、
959f4b34d6f4 add final thesis
soto
parents:
diff changeset
27 条件を満たしているのかをMeta CodeGear で検証する。
959f4b34d6f4 add final thesis
soto
parents:
diff changeset
28
4
bf1f62556b81 add while_test_init_imple
soto
parents: 3
diff changeset
29 \begin{figure}[H]
bf1f62556b81 add while_test_init_imple
soto
parents: 3
diff changeset
30 \begin{center}
bf1f62556b81 add while_test_init_imple
soto
parents: 3
diff changeset
31 \includegraphics[height=3.4cm]{pic/hoare_cg_dg.pdf}
bf1f62556b81 add while_test_init_imple
soto
parents: 3
diff changeset
32 \end{center}
bf1f62556b81 add while_test_init_imple
soto
parents: 3
diff changeset
33 \caption{CodeGear、DataGear での Hoare Logic}
bf1f62556b81 add while_test_init_imple
soto
parents: 3
diff changeset
34 \label{hoare}
bf1f62556b81 add while_test_init_imple
soto
parents: 3
diff changeset
35 \end{figure}
bf1f62556b81 add while_test_init_imple
soto
parents: 3
diff changeset
36
11
1cde48f23236 FIN proto
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
37 \begin{comment}
4
bf1f62556b81 add while_test_init_imple
soto
parents: 3
diff changeset
38 \section{CbCでの Hoare Logic を用いた検証}
bf1f62556b81 add while_test_init_imple
soto
parents: 3
diff changeset
39 先行研究で行われている While Loop の Hoare Logic での検証を元に、
bf1f62556b81 add while_test_init_imple
soto
parents: 3
diff changeset
40 実際の Hoare Logic を用いた検証手法について解説する。
bf1f62556b81 add while_test_init_imple
soto
parents: 3
diff changeset
41
bf1f62556b81 add while_test_init_imple
soto
parents: 3
diff changeset
42 \subsection{CbC でのコードとそれに対応したAgdaのコード}
bf1f62556b81 add while_test_init_imple
soto
parents: 3
diff changeset
43
bf1f62556b81 add while_test_init_imple
soto
parents: 3
diff changeset
44 元となる CbC での コードとそれと対応した Agda のコードを以下に示す。
bf1f62556b81 add while_test_init_imple
soto
parents: 3
diff changeset
45
bf1f62556b81 add while_test_init_imple
soto
parents: 3
diff changeset
46 \subsection{}
bf1f62556b81 add while_test_init_imple
soto
parents: 3
diff changeset
47
bf1f62556b81 add while_test_init_imple
soto
parents: 3
diff changeset
48 実装の際には、(next : Env → t)で Continuation に対応していた。
bf1f62556b81 add while_test_init_imple
soto
parents: 3
diff changeset
49 これに加えてHoare Triple に対応する。
bf1f62556b81 add while_test_init_imple
soto
parents: 3
diff changeset
50 そのため Env → t の間に Meta Data Gear を記述する
bf1f62556b81 add while_test_init_imple
soto
parents: 3
diff changeset
51 以下は Meta Data Gear の記述
bf1f62556b81 add while_test_init_imple
soto
parents: 3
diff changeset
52 % Meta Data Gearのソースコードを貼る
bf1f62556b81 add while_test_init_imple
soto
parents: 3
diff changeset
53
bf1f62556b81 add while_test_init_imple
soto
parents: 3
diff changeset
54 s1 が初期状態、
11
1cde48f23236 FIN proto
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
55 \end{comment}
3
959f4b34d6f4 add final thesis
soto
parents:
diff changeset
56
959f4b34d6f4 add final thesis
soto
parents:
diff changeset
57