-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinvariant.tex
402 lines (378 loc) · 13.2 KB
/
invariant.tex
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
\documentclass[a4paper,conference]{llncs}
\usepackage{colortbl}
\newcommand{\dkcmt}[1]{{\color{red} [{#1}]}}
\newcommand{\rmcmt}[1]{{\color{magenta} [{#1}]}}
\newcommand{\sjcmt}[1]{{\color{blue} [{#1}]}}
\newcommand{\tmcmt}[1]{{\color{orange} [{#1}]}}
\usepackage{xspace}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,positioning,decorations.markings,chains,fit,shapes.multipart}
\usepackage{import}
\usepackage{times}
\usepackage{graphicx}
\usepackage{cite}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{mathptm}
\usepackage{rotating}
\usepackage{color}
\usepackage{listings}
\usepackage{verbatim}
\usepackage{comment}
\usepackage{alltt}
\usepackage{mdwlist}
\usepackage{booktabs}
\usepackage[algo2e,linesnumbered,ruled,lined]{algorithm2e}
\usepackage{hyperref}
\makeatother
\newcommand{\tool}[1]{\textsc{#1}\xspace}
\newcommand{\hector}{\tool{hector}}
\newcommand{\slec}{\tool{slec}}
\newcommand{\hwcbmcv}{\tool{hw-cbmc}}
\newcommand{\hwcbmcver}{\tool{hw-cbmc 5.4}}
\newcommand{\verifoxver}{\tool{VerifOx 0.1}}
\newcommand{\verifox}{\tool{VerifOx}}
\newcommand{\klee}{\tool{klee}}
\newcommand{\kleever}{\tool{klee 1.0.0}}
\newcommand{\symbiotic}{\tool{symbiotic}}
\newcommand{\Omit}[1]{}
\newcommand{\scs}[1]{\scriptsize{#1}}
\input{symbols}
\begin{document}
\title{Invariant Generation using ACDL}
\author{}
\institute{}
\maketitle
\section{Algorithm for Invariant Generation}
\Omit{
We propose a two-solver approach for proving programs with loops using ACDL.
Let us call these solvers: \em{proof solver} (PS) and \em{invariant solver} (IS).
The purpose of proof solver is to determine the safety of the program in the
presence of the negation of assertion. Whereas, the purpose of invariant solver is
to determine the inductivenss of the candidate invariant produced by the proof
solver in the presence of the actual assertion.
}
We present a program verification algorithm, ACDCL-P, inspired
from the propositional-level CDCL algorithm. ACDCL-P generates a candidate
invariant following decisions and deductions. The inductiveness of the
candidate invariants are then checked using an Abstract CDCL solver, ACDCL. ACDCL
solver returns SAT if the input formula is satisfiable and UNSAT otherwise.
\section{Communication between ACDCL and ACDCL-P}
The deduction information in the trail corresponding to
decisions that participate in the invariant can be
communicated from ACDCL-P to ACDCL.
\subsection{Highlights of ACDCL-P}
\begin{enumerate}
\item decision heuristics on cond variables enable us to prove many
programs without actually deciding on the actual program variables. This
leads to significantly less number of decisions and less number of conflicts
compared to the SAT solver. Further, decisions on conditional program
variables can be seen as simulating path-based symbolic execution. But when
a decision on conditional varaible leads to BOTTOM, ACDCL-P tried to learn
the reason for failure, and hence can also be seen similar to IMPACT like
algorithm.
\item Last UIP allows us to learn clauses that has more information in it.
\item Compared to pure AI based tools, ACDCL-P performs program and property
driven partitioning with simpler domains to prove programs with relational
properties (branch7). AI based tool would require richer domains like
relational (equality) domain to prove such programs.
\item Compared to cdfpl, our tool proves more programs correctly and works on
non-numeric programs as well.
\item Chaotic propagations help ACDCL-P to generate stronger deductions and reach
fixpoint early in propagation stage.
\item Compared to cdfpl, acdl solver is agnostic to abstract domain. cdfpl
stores the value of variables (from interval domain) in every decision
and deduction stage in a container "value". So, cdfpl keeps track of literals
and their intervals at every stage which makes it difficult to extend it to other
richer domains. However, ACDCL-P treat literals as meet irreducibles. Hence,
ACDCL-P can be easily extended to other richer domains.
\item ACDL computes learnt clause with UIP for octagon domains -- first time
extension of learning in ACDL to richer relational domains.
\item ACDCL-P handles loops by automatic invariant generation.
\end{enumerate}
\subsection{Difference between cdfpl and ACDCL-P}
\begin{enumerate}
\item cdfpl stores deductions from conflict clause into the trail. It does not
store the deductions from the AI phase into the propagation trail. Hence, each
entry in the trail has a corresponding reason (conflict clause responsible for
deducing the literal in the entry). Thus, it is easier to compute the UIP in
cdfpl since it retains only the clause based deduction information in the trail.
Thus, it can perform resolution proof easily to compute the UIP. The resolution
proof in cdfpl is implemented in a way that it iterates through the marked
portion of the trail (contradicted portion in the current decision segment of
the trail with respect to the conflict clause) to find the corresponding clause
(predecessor clause) for each marked entry in the DL segment of the trail
(Note that the predecessor clause is the one which inferred this literal in the
trail). The predecessor clause is then iterated to find if a literal in the
clause is contradicted in the current decision level or previous decision level
and accordingly the learnt clause and the backtrack level is updated.
\item Whereas, ACDCL-P stores the deduction information from the AI phase into the
trail. In such case, the entries in the trail does not have a corresponding
reason clause. Thus, it is not possible to perform resolution proof to find the
UIP since the propagation trail does not store such information.
\item unitness is guaranteed in propagation in CDCL — that is all deduction are
made through unit clause. Whereas, unitness is not guaranteed in propagation in
ACDCL — that is deduction in AI phase are not made through unit clause, but deductions
made through conflict clause are only unit. Thus, resolution proof is not possible.
\end{enumerate}
\textbf{Lemma 1:}Normalization is an equivalent transformation. \\
\textbf{Lemma 2:}Normalizing a learnt clause is UNIT preserving. \\
Proof: Prove that the above lemma holds both for monotonic ($x \leq 2 \land x \leq 1
\land x \leq 0)$ and non-monotonic decisions $(x \leq 20 \land x \geq 10 \land
x \leq 15 \land x \leq 13)$. \\
\textbf{Lemma 3:}Normalizing a learnt clause does not affect the backtrack
level. \\
\begin{enumerate}
\item Step 1: Construct the learnt clause, L=${\neg{d1} \lor \neg{d2} \lor \neg{UIP}}$
\item Step 2: Normalize the learnt clause without UIP, normalize L'=${\neg{d1} \lor \neg{d2}}$
\item Step 3: Add the UIP to the normalized learnt clause, L\_final=L' $\lor \neg{UIP}$
\item Step 4: Backtrack to blevel=$max\{d1, d2\}$
\item Step 5: Let $val$ be the current partial assignment after backtracking
\item Step 6: Normalize the current partial assignment, $val$
\item Step 7: Check unit rule for (L\_final, val) -- The learnt clause should now be UNIT !
\end{enumerate}
\subsection{Some ideas}
\begin{enumerate}
\item Can we infer the smallest UNSAT core when we reach BOTTOM
as the potential candidate for Invariant. If the UNSAT core for
a proof is indeed an invariant, then it will be UNSAT core for other proofs
as well.
\end{enumerate}
\begin{algorithm2e}[t]
\DontPrintSemicolon
\SetKwFunction{decide}{Decide}
\SetKwFunction{deduce}{deduce}
\SetKwFunction{backtrack}{backtrack}
\SetKwFunction{print}{print}
\SetKwFunction{return}{return}
\SetKwFunction{nondet}{nondet}
\SetKwFunction{run}{run}
\SetKwFunction{learn}{learn}
\SetKwFunction{continue}{continue}
\SetKwFunction{assign}{assign}
\SetKwRepeat{Do}{do}{while}
%\SetKwFunction{assume}{assume}
%\SetKwFunction{isf}{isFeasible}
\SetKwData{safe}{safe}
\SetKwData{unsafe}{unsafe}
\SetKwData{sat}{sat}
\SetKwData{unsat}{unsat}
\SetKwData{unknown}{unknown}
\SetKwData{true}{true}
\SetKwInOut{Input}{input}
\SetKwInOut{Output}{output}
\SetKw{KwNot}{not}
\begin{small}
\Input{Formula $\mathcal{F}$}
\Output{The status (\sat or \unsat or \unknown)}
result=\deduce(F)\;
\uIf{$result == \perp$} {
\return \unsat \;
}
\uElse
{
$t$ = get\_satisfying\_assignment($F$) \;
\uIf{spurious\_check(t)}
{
\return \sat \;
}
}
\While{$true$}
{
meet\_irreducible = decision\_heuristics($F$)\;
decision\_container = decision\_container $\cup$ meet\_irreducible\;
\uIf{meet\_irreducible == NULL}
{
return \unknown\;
}
\uElse
{
\assign result=\deduce(F)\;
\uIf{result == UNKNOWN}
{
$t$ = get\_satisfying\_assignment($F$) \;
\uIf{spurious\_check(t)}
{
\return \sat \;
}
\uElse
{
\continue\;
}
}
\uElse
{
\Do{result == PASS} {
\uIf{$\neg$ conflict\_analysis()} {
return \unsat \;
}
\assign result=\deduce(F)\;
}
}
}
}
\end{small}
\caption{ACDCL Solver \label{Alg:acdl}}
\end{algorithm2e}
\begin{algorithm2e}[t]
\DontPrintSemicolon
\SetKwFunction{decide}{Decide}
\SetKwFunction{deduce}{deduce}
\SetKwFunction{backtrack}{backtrack}
\SetKwFunction{print}{print}
\SetKwFunction{return}{return}
\SetKwFunction{nondet}{nondet}
\SetKwFunction{run}{run}
\SetKwFunction{learn}{learn}
\SetKwFunction{continue}{continue}
\SetKwFunction{assign}{assign}
\SetKwRepeat{Do}{do}{while}
%\SetKwFunction{assume}{assume}
%\SetKwFunction{isf}{isFeasible}
\SetKwData{safe}{safe}
\SetKwData{unsafe}{unsafe}
\SetKwData{unknown}{unknown}
\SetKwData{true}{true}
\SetKwInOut{Input}{input}
\SetKwInOut{Output}{output}
\SetKw{KwNot}{not}
\begin{small}
\Input{Program $\mathcal{P}$ with properties specified with $assert(c)$}
\Output{The status (\safe or \unsafe) and a counterexample if \unsafe}
%\tcc{The initial state}
$ACDCL-P \leftarrow \tuple{\neg(assert(c)),loopselect=nondet}$ \nllabel{algline:initPS}\;
result=\deduce(P)\;
\uIf{$result == \perp$} {
\return \safe \;
}
\uElse
{
$t$ = get\_counterexample\_trace\_from\_P \;
\uIf{spurious\_check(t)} {
\return \unsafe \;
}
}
\While{$true$}
{
meet\_irreducible = decision\_heuristics($P$)\;
decision\_container = decision\_container $\cup$ meet\_irreducible \;
\uIf{meet\_irreducible == NULL}
{
return \unknown\;
}
\uElse
{
result=\deduce(P)\;
\uIf{result == UNKNOWN}
{
$t$ = get\_counterexample\_trace\_from\_P \;
\uIf{spurious\_check(t)} {
\return \unsafe \;
}
\uElse
{
\continue\;
}
}
\uElse
{
\Do{$result == \perp$} {
\uIf {loop\_variable $\in$ decision\_container} {
$Inv=(\bigcap_{i=1}^{n} d_{i} \rightarrow
\bigcap_{j=1}^{m} l_{j})$ where $d_i$ $\in$ \{non\_loop\_variable
$\cup$ loop\_variable\}, $l_j$ $\in$ \{loop\_variable\} \nllabel{algline:inv}\;
Inv\_formula = $Inv$ $\wedge$ $P$ $\wedge$ $\neg{Inv'}$, where $Inv'$
is the invariant after the application of transition system\;
$inv\_result \leftarrow$ run($ACDCL$, $Inv\_formula$) \;
\uIf{inv\_result == UNSAT \nllabel{algline:statusIS}} {
\learn $Inv$ \;
}
}
\uIf{$\neg$ conflict\_analysis()} {
return \safe \;
}
result=\deduce(P)\;
}
}
}
}
\end{small}
\caption{ACDCL-P Verifier with Invariant Checking\label{Alg:verifox}}
\end{algorithm2e}
\begin{algorithm2e}[t]
\DontPrintSemicolon
\SetKwFunction{decide}{Decide}
\SetKwFunction{deduce}{deduce}
\SetKwFunction{backtrack}{backtrack}
\SetKwFunction{print}{print}
\SetKwFunction{return}{return}
\SetKwFunction{nondet}{nondet}
\SetKwFunction{run}{run}
\SetKwFunction{learn}{learn}
\SetKwFunction{continue}{continue}
\SetKwFunction{assign}{assign}
\SetKwRepeat{Do}{do}{while}
%\SetKwFunction{assume}{assume}
%\SetKwFunction{isf}{isFeasible}
\SetKwData{safe}{safe}
\SetKwData{unsafe}{unsafe}
\SetKwData{true}{true}
\SetKwData{false}{false}
\SetKwInOut{Input}{input}
\SetKwInOut{Output}{output}
\SetKw{KwNot}{not}
\begin{small}
\Input{A counterexample trace $t$ of Program $P$}
\Output{The status (\true) if $t$ is not spurious and $t$ is complete
or (\false) if $t$ is spurious or not complete}
\uIf{loopselect $\in$ t} {
\uIf{loopselect==false} {
\uIf{gamma\_complete(t)} {
return \true \;
}
\uElse
{
return \false \;
}
}
\uElse {
return \false \;
}
}
\end{small}
\caption{Spurious Counterexample Check \label{Alg:spurious-check}}
\end{algorithm2e}
\begin{algorithm2e}[t]
\DontPrintSemicolon
\SetKwFunction{decide}{Decide}
\SetKwFunction{deduce}{deduce}
\SetKwFunction{backtrack}{backtrack}
\SetKwFunction{print}{print}
\SetKwFunction{return}{return}
\SetKwFunction{nondet}{nondet}
\SetKwFunction{run}{run}
\SetKwFunction{learn}{learn}
\SetKwFunction{continue}{continue}
\SetKwFunction{assign}{assign}
\SetKwRepeat{Do}{do}{while}
\SetKwData{safe}{safe}
\SetKwData{unsafe}{unsafe}
\SetKwData{true}{true}
\SetKwData{false}{false}
\SetKwInOut{Input}{input}
\SetKwInOut{Output}{output}
\SetKw{KwNot}{not}
\begin{small}
\Input{A counterexample trace $t$ of Program $P$}
\Output{The status (\true) if $t$ is complete, else \false if $t$ is not complete}
\For{elements $e \in t$} {
\uIf{$e$ is non-singleton} {
return \false \;
}
}
return \true \;
\end{small}
\caption{Gamma Completeness Check \label{Alg:gamma-complete}}
\end{algorithm2e}
\end{document}