-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path11_.tex
More file actions
149 lines (146 loc) · 2.03 KB
/
11_.tex
File metadata and controls
149 lines (146 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{mathtools}
\DeclareMathAlphabet{\mathpzc}{OT1}{pzc}{m}{it}
\title{The Hoare Triple}
\author{Krystal Maughan }
\date{April 28th 2017}
\begin{document}
\maketitle
\section{The Hoare Triple : Simultaneous Assignment}
Problems in Simultaneous Assignment
\\
\\
\section{Homework 2.3.5.1}
Evaluate
\\
\\
wp("$i : = i + 1; j : = 2i$" , $2i = j$)
\\
\\
TRUE
\\
\\
wp("$j : 2i; i : = i + 1$", $2i = j$)
\\
\\
FALSE
\\
\\
wp("$i, j : = i + 1, 2i$", $2i = j$)
\\
\\
FALSE
\\
\\
\\
\\
\\
\\
\\
\\
\\
\section{Homework 2.3.5.2}
Prove the following code segment correct.
\\
It swaps the values of variables x and y.
\\
\\
$\left\{Q: x = \hat{x} \land (y = \hat{y}\right\}$
\\
$S : x, y : = y , x$
\\
$\left\{R: x = \hat{y} \land (y = \hat{x}\right\}$
\\
\\
$Q \Rightarrow wp("S", R)$
\\
\\
$<$ Instantiate S and R $>$
\\
\\
$Q \Rightarrow wp("x, y : = y, x", (x = \hat{y}) \land (y = \hat{x}))$
\\
\\
$<$ Definition of $wp(: =,) >$
\\
\\
$Q \Rightarrow {(( x = \hat{y}) \land (y = \hat{x})}_{(y),(x)}^{x, y}$
\\
\\
$<$ Instantiate $Q$, definition of $R_{(y),(x)}^{x,y} >$
\\
\\
$((x = \hat{x} \land (y = \hat{y})) \Rightarrow ((y = \hat{y}) \land (x = \hat{x}))$
\\
\\
$<$ $\land$-commutivity; $\Rightarrow$-simplification $>$
\\
\\
T
\\
\\
\section{Homework 2.3.5.3}
Evaluate
\\
\\
wp($i : = 2i + j; j : = i + 2j + 4$", $i = j$)
\\
\\
$<$ definition of $: = $ $>$
\\
\\
wp("$i : = 2i + j$", $i = i + 2j + 4$)
\\
\\
$<$ definition of $: = $ $>$
\\
\\
wp("$i : = 2i + j$", $i = i + 2j + 4$)
\\
\\
simplification $\rightarrow$ $j = -2$
\\
\\
\\
\\
Evaluate
\\
\\
wp("$j : = i + 2j + 4; i : = 2i + j$", $i = j$)
\\
\\
$<$ definition of $: = $ $>$
\\
\\
wp("$j : = i + 2j + 4$", $2i + j = j$)
\\
\\
$<$ definition of $: = $ $>$
\\
\\
$2i + (i + 2j + 4) = i + 2j + 4$
\\
\\
simplification $\Rightarrow i = 0$
\\
\\
\\
\\
\\
\\
Evaluate
\\
\\
wp("$i, j: = 2i + j, i + 2j + 4$", $i = j$)
\\
\\
$<$ definition of $: = $ $>$
\\
\\
$2i + j = i + 2j + 4$
\\
\\
simplification $\Rightarrow i = j + 4$
\end{document}