File size: 21,982 Bytes
bff4ec7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
Require Import Coq.ZArith.ZArith.
Require Import Coq.Bool.Bool.
Require Import Coq.Strings.String.
Require Import Coq.Strings.Ascii.
Require Import Coq.Lists.List.
Require Import Coq.Classes.RelationClasses.
Require Import Coq.Classes.Morphisms.
Require Import Coq.micromega.Psatz.
Require Import Coq.Sorting.Permutation.
From AUXLib Require Import int_auto Axioms Feq Idents ListLib VMap.
Require Import SetsClass.SetsClass. Import SetsNotation.
From SimpleC.SL Require Import Mem SeparationLogic.
Require Import Logic.LogicGenerator.demo932.Interface.
Local Open Scope Z_scope.
Local Open Scope sets.
Local Open Scope string_scope.
Local Open Scope list.
Import naive_C_Rules.
Require Import PVbench.Data_structures.stack.rocq.spec_lib.
Local Open Scope sac.

(*----- Function push -----*)

Definition push_entail_wit_1 := 
(
forall (n_pre: Z) (stack_pre: Z) (before: sll) (PreH1 : (n_pre < stack_capacity)) ,
  (store_stack stack_pre before n_pre )
  **  (IntArray.undef_seg stack_pre n_pre (n_pre + 1 ) )
|--
  EX (concrete: (@list Z)) ,
  “ (0 <= n_pre) ” 
  &&  “ (n_pre < stack_capacity) ” 
  &&  “ (StackConcreteView before concrete n_pre ) ”
  &&  (IntArray.full stack_pre n_pre concrete )
  **  (IntArray.undef_seg stack_pre n_pre (n_pre + 1 ) )
) \/
(
forall (n_pre: Z) (stack_pre: Z) (before: sll) (PreH1 : (n_pre < stack_capacity)) ,
  (store_stack stack_pre before n_pre )
|--
  EX (concrete: (@list Z)) ,
  “ (0 <= n_pre) ” 
  &&  “ (n_pre < stack_capacity) ” 
  &&  “ (StackConcreteView before concrete n_pre ) ”
  &&  (IntArray.full stack_pre n_pre concrete )
).

Definition push_entail_wit_2 := 
(
forall (x_pre: Z) (n_pre: Z) (stack_pre: Z) (before: sll) (concrete: (@list Z)) (PreH1 : (0 <= n_pre)) (PreH2 : (n_pre < stack_capacity)) (PreH3 : (StackConcreteView before concrete n_pre )) ,
  (IntArray.full stack_pre (n_pre + 1 ) (app (concrete) ((cons (x_pre) ((@nil Z))))) )
|--
  “ (0 <= n_pre) ” 
  &&  “ (n_pre < stack_capacity) ”
  &&  (store_stack stack_pre (sll_cons (x_pre) (before)) (n_pre + 1 ) )
) \/
(
forall (x_pre: Z) (n_pre: Z) (stack_pre: Z) (before: sll) (concrete: (@list Z)) (PreH1 : (0 <= n_pre)) (PreH2 : (n_pre < stack_capacity)) (PreH3 : (StackConcreteView before concrete n_pre )) ,
  (IntArray.full stack_pre (n_pre + 1 ) (app (concrete) ((cons (x_pre) ((@nil Z))))) )
|--
  (store_stack stack_pre (sll_cons (x_pre) (before)) (n_pre + 1 ) )
).

Definition push_entail_wit_2_split_goal_spatial := 
forall (x_pre: Z) (n_pre: Z) (stack_pre: Z) (before: sll) (concrete: (@list Z)) (PreH1 : (0 <= n_pre)) (PreH2 : (n_pre < stack_capacity)) (PreH3 : (StackConcreteView before concrete n_pre )) ,
  (IntArray.full stack_pre (n_pre + 1 ) (app (concrete) ((cons (x_pre) ((@nil Z))))) )
|--
  (store_stack stack_pre (sll_cons (x_pre) (before)) (n_pre + 1 ) )
.

Definition push_return_wit_1 := 
forall (x_pre: Z) (n_pre: Z) (stack_pre: Z) (before: sll) (PreH1 : (0 <= n_pre)) (PreH2 : (n_pre < stack_capacity)) ,
  (store_stack stack_pre (sll_cons (x_pre) (before)) (n_pre + 1 ) )
|--
  (store_stack stack_pre (sll_cons (x_pre) (before)) (n_pre + 1 ) )
.

Definition push_partial_solve_wit_1 := 
forall (n_pre: Z) (stack_pre: Z) (before: sll) (concrete: (@list Z)) (PreH1 : (0 <= n_pre)) (PreH2 : (n_pre < stack_capacity)) (PreH3 : (StackConcreteView before concrete n_pre )) ,
  (IntArray.full stack_pre n_pre concrete )
  **  (IntArray.undef_seg stack_pre n_pre (n_pre + 1 ) )
|--
  “ (0 <= n_pre) ” 
  &&  “ (n_pre < stack_capacity) ” 
  &&  “ (StackConcreteView before concrete n_pre ) ”
  &&  (((stack_pre + (n_pre * sizeof(INT)))) # Int  |->_)
  **  (IntArray.full stack_pre n_pre concrete )
.

(*----- Function pop -----*)

Definition pop_safety_wit_1 := 
forall (n_pre: Z) (stack_pre: Z) (rest: sll) (top: Z) (concrete: (@list Z)) (PreH1 : (1 <= n_pre)) (PreH2 : (n_pre <= stack_capacity)) (PreH3 : (StackConcreteView (sll_cons (top) (rest)) concrete n_pre )) ,
  ((( &( "ret" ) )) # Int  |->_)
  **  ((( &( "stack" ) )) # Ptr  |-> stack_pre)
  **  ((( &( "n" ) )) # Int  |-> n_pre)
  **  (IntArray.full stack_pre n_pre concrete )
|--
  “ ((n_pre - 1 ) <= INT_MAX) ” 
  &&  “ ((INT_MIN) <= (n_pre - 1 )) ”
.

Definition pop_safety_wit_2 := 
forall (n_pre: Z) (stack_pre: Z) (rest: sll) (top: Z) (concrete: (@list Z)) (PreH1 : (1 <= n_pre)) (PreH2 : (n_pre <= stack_capacity)) (PreH3 : (StackConcreteView (sll_cons (top) (rest)) concrete n_pre )) ,
  ((( &( "ret" ) )) # Int  |->_)
  **  ((( &( "stack" ) )) # Ptr  |-> stack_pre)
  **  ((( &( "n" ) )) # Int  |-> n_pre)
  **  (IntArray.full stack_pre n_pre concrete )
|--
  “ (1 <= INT_MAX) ” 
  &&  “ ((INT_MIN) <= 1) ”
.

Definition pop_entail_wit_1 := 
(
forall (n_pre: Z) (stack_pre: Z) (rest: sll) (top: Z) (PreH1 : (1 <= n_pre)) ,
  (store_stack stack_pre (sll_cons (top) (rest)) n_pre )
|--
  EX (concrete: (@list Z)) ,
  “ (1 <= n_pre) ” 
  &&  “ (n_pre <= stack_capacity) ” 
  &&  “ (StackConcreteView (sll_cons (top) (rest)) concrete n_pre ) ”
  &&  (IntArray.full stack_pre n_pre concrete )
) \/
(
forall (n_pre: Z) (stack_pre: Z) (rest: sll) (top: Z) (PreH1 : (1 <= n_pre)) ,
  (store_stack stack_pre (sll_cons (top) (rest)) n_pre )
|--
  EX (concrete: (@list Z)) ,
  “ (1 <= n_pre) ” 
  &&  “ (n_pre <= stack_capacity) ” 
  &&  “ (StackConcreteView (sll_cons (top) (rest)) concrete n_pre ) ”
  &&  (IntArray.full stack_pre n_pre concrete )
).

Definition pop_entail_wit_2 := 
(
forall (n_pre: Z) (stack_pre: Z) (rest: sll) (top: Z) (concrete: (@list Z)) (PreH1 : (1 <= n_pre)) (PreH2 : (n_pre <= stack_capacity)) (PreH3 : (StackConcreteView (sll_cons (top) (rest)) concrete n_pre )) ,
  (IntArray.full stack_pre n_pre concrete )
  **  ((( &( "ret" ) )) # Int  |-> (Znth (n_pre - 1 ) concrete 0))
|--
  “ (1 <= n_pre) ” 
  &&  “ (n_pre <= stack_capacity) ”
  &&  ((( &( "ret" ) )) # Int  |-> top)
  **  (store_stack stack_pre rest (n_pre - 1 ) )
  **  (IntArray.undef_seg stack_pre (n_pre - 1 ) n_pre )
) \/
(
forall (n_pre: Z) (stack_pre: Z) (rest: sll) (top: Z) (concrete: (@list Z)) (PreH1 : (1 <= n_pre)) (PreH2 : (n_pre <= stack_capacity)) (PreH3 : (StackConcreteView (sll_cons (top) (rest)) concrete n_pre )) ,
  (IntArray.full stack_pre n_pre concrete )
|--
  “ ((Znth (n_pre - 1 ) concrete 0) = top) ”
  &&  (store_stack stack_pre rest (n_pre - 1 ) )
  **  (IntArray.undef_seg stack_pre (n_pre - 1 ) n_pre )
).

Definition pop_entail_wit_2_split_goal_1 := 
forall (n_pre: Z) (stack_pre: Z) (rest: sll) (top: Z) (concrete: (@list Z)) (PreH1 : (1 <= n_pre)) (PreH2 : (n_pre <= stack_capacity)) (PreH3 : (StackConcreteView (sll_cons (top) (rest)) concrete n_pre )) ,
  (IntArray.full stack_pre n_pre concrete )
|--
  “ ((Znth (n_pre - 1 ) concrete 0) = top) ”
.

Definition pop_entail_wit_2_split_goal_spatial := 
forall (n_pre: Z) (stack_pre: Z) (rest: sll) (top: Z) (concrete: (@list Z)) (PreH1 : (1 <= n_pre)) (PreH2 : (n_pre <= stack_capacity)) (PreH3 : (StackConcreteView (sll_cons (top) (rest)) concrete n_pre )) ,
  (IntArray.full stack_pre n_pre concrete )
|--
  (store_stack stack_pre rest (n_pre - 1 ) )
  **  (IntArray.undef_seg stack_pre (n_pre - 1 ) n_pre )
.

Definition pop_return_wit_1 := 
forall (n_pre: Z) (stack_pre: Z) (rest: sll) (top: Z) (PreH1 : (1 <= n_pre)) (PreH2 : (n_pre <= stack_capacity)) ,
  (store_stack stack_pre rest (n_pre - 1 ) )
  **  (IntArray.undef_seg stack_pre (n_pre - 1 ) n_pre )
|--
  “ (top = top) ”
  &&  (store_stack stack_pre rest (n_pre - 1 ) )
  **  (IntArray.undef_seg stack_pre (n_pre - 1 ) n_pre )
.

Definition pop_partial_solve_wit_1 := 
forall (n_pre: Z) (stack_pre: Z) (rest: sll) (top: Z) (concrete: (@list Z)) (PreH1 : (1 <= n_pre)) (PreH2 : (n_pre <= stack_capacity)) (PreH3 : (StackConcreteView (sll_cons (top) (rest)) concrete n_pre )) ,
  (IntArray.full stack_pre n_pre concrete )
|--
  “ (1 <= n_pre) ” 
  &&  “ (n_pre <= stack_capacity) ” 
  &&  “ (StackConcreteView (sll_cons (top) (rest)) concrete n_pre ) ”
  &&  (((stack_pre + ((n_pre - 1 ) * sizeof(INT)))) # Int  |-> (Znth (n_pre - 1 ) concrete 0))
  **  (IntArray.missing_i stack_pre (n_pre - 1 ) 0 n_pre concrete )
.

(*----- Function build -----*)

Definition build_safety_wit_1 := 
forall (n_pre: Z) (stack_pre: Z) (input: (@list Z)) (PreH1 : (0 <= n_pre)) (PreH2 : (n_pre <= stack_capacity)) (PreH3 : ((Zlength (input)) = n_pre)) ,
  ((( &( "i" ) )) # Int  |->_)
  **  ((( &( "stack" ) )) # Ptr  |-> stack_pre)
  **  ((( &( "n" ) )) # Int  |-> n_pre)
  **  (IntArray.full stack_pre n_pre input )
|--
  “ (1 <= INT_MAX) ” 
  &&  “ ((INT_MIN) <= 1) ”
.

Definition build_safety_wit_2 := 
forall (n_pre: Z) (stack_pre: Z) (input: (@list Z)) (i: Z) (PreH1 : (i < n_pre)) (PreH2 : (n_pre = 0)) (PreH3 : (i = 1)) (PreH4 : ((Zlength (input)) = n_pre)) ,
  ((( &( "stack" ) )) # Ptr  |-> stack_pre)
  **  ((( &( "n" ) )) # Int  |-> n_pre)
  **  ((( &( "i" ) )) # Int  |-> i)
  **  (IntArray.full stack_pre n_pre input )
|--
  “ False ”
.

Definition build_safety_wit_3 := 
forall (n_pre: Z) (stack_pre: Z) (input: (@list Z)) (next: sll) (i: Z) (x: Z) (PreH1 : (1 <= n_pre)) (PreH2 : (n_pre <= stack_capacity)) (PreH3 : (1 <= i)) (PreH4 : (i < n_pre)) (PreH5 : (x = (Znth i input 0))) (PreH6 : ((Zlength (input)) = n_pre)) (PreH7 : (BuildStackPrefix next input (i + 1 ) )) ,
  ((( &( "stack" ) )) # Ptr  |-> stack_pre)
  **  ((( &( "n" ) )) # Int  |-> n_pre)
  **  ((( &( "i" ) )) # Int  |-> i)
  **  (store_stack stack_pre next (i + 1 ) )
  **  (IntArray.seg stack_pre (i + 1 ) n_pre (sublist ((i + 1 )) (n_pre) (input)) )
|--
  “ ((i + 1 ) <= INT_MAX) ” 
  &&  “ ((INT_MIN) <= (i + 1 )) ”
.

Definition build_entail_wit_1 := 
forall (n_pre: Z) (stack_pre: Z) (input: (@list Z)) (PreH1 : (0 <= n_pre)) (PreH2 : (n_pre <= stack_capacity)) (PreH3 : ((Zlength (input)) = n_pre)) ,
  (IntArray.full stack_pre n_pre input )
|--
  (“ (n_pre = 0) ” 
  &&  “ (1 = 1) ” 
  &&  “ ((Zlength (input)) = n_pre) ”
  &&  (IntArray.full stack_pre n_pre input ))
  ||
  (EX (prefix: sll) ,
  “ (1 <= n_pre) ” 
  &&  “ (n_pre <= stack_capacity) ” 
  &&  “ (1 <= 1) ” 
  &&  “ (1 <= n_pre) ” 
  &&  “ ((Zlength (input)) = n_pre) ” 
  &&  “ (BuildStackPrefix prefix input 1 ) ”
  &&  (store_stack stack_pre prefix 1 )
  **  (IntArray.seg stack_pre 1 n_pre (sublist (1) (n_pre) (input)) ))
.

Definition build_entail_wit_2 := 
(
forall (n_pre: Z) (stack_pre: Z) (input: (@list Z)) (prefix_2: sll) (i: Z) (PreH1 : (i < n_pre)) (PreH2 : (1 <= n_pre)) (PreH3 : (n_pre <= stack_capacity)) (PreH4 : (1 <= i)) (PreH5 : (i <= n_pre)) (PreH6 : ((Zlength (input)) = n_pre)) (PreH7 : (BuildStackPrefix prefix_2 input i )) ,
  (IntArray.seg stack_pre i n_pre (sublist (i) (n_pre) (input)) )
  **  (store_stack stack_pre prefix_2 i )
|--
  EX (prefix: sll) ,
  “ (1 <= n_pre) ” 
  &&  “ (n_pre <= stack_capacity) ” 
  &&  “ (1 <= i) ” 
  &&  “ (i < n_pre) ” 
  &&  “ ((Znth (i - i ) (sublist (i) (n_pre) (input)) 0) = (Znth i input 0)) ” 
  &&  “ ((Zlength (input)) = n_pre) ” 
  &&  “ (BuildStackPrefix prefix input i ) ”
  &&  (store_stack stack_pre prefix i )
  **  (IntArray.undef_seg stack_pre i (i + 1 ) )
  **  (IntArray.seg stack_pre (i + 1 ) n_pre (sublist ((i + 1 )) (n_pre) (input)) )
) \/
(
forall (n_pre: Z) (stack_pre: Z) (input: (@list Z)) (prefix_2: sll) (i: Z) (PreH1 : (i < n_pre)) (PreH2 : (1 <= n_pre)) (PreH3 : (n_pre <= stack_capacity)) (PreH4 : (1 <= i)) (PreH5 : (i <= n_pre)) (PreH6 : ((Zlength (input)) = n_pre)) (PreH7 : (BuildStackPrefix prefix_2 input i )) ,
  (IntArray.seg stack_pre i n_pre (sublist (i) (n_pre) (input)) )
  **  (store_stack stack_pre prefix_2 i )
|--
  EX (prefix: sll) ,
  “ (1 <= n_pre) ” 
  &&  “ (n_pre <= stack_capacity) ” 
  &&  “ (1 <= i) ” 
  &&  “ (i < n_pre) ” 
  &&  “ ((Znth (i - i ) (sublist (i) (n_pre) (input)) 0) = (Znth i input 0)) ” 
  &&  “ ((Zlength (input)) = n_pre) ” 
  &&  “ (BuildStackPrefix prefix input i ) ”
  &&  (store_stack stack_pre prefix i )
  **  (IntArray.undef_seg stack_pre i (i + 1 ) )
  **  (IntArray.seg stack_pre (i + 1 ) n_pre (sublist ((i + 1 )) (n_pre) (input)) )
).

Definition build_entail_wit_3 := 
(
forall (n_pre: Z) (stack_pre: Z) (input: (@list Z)) (prefix: sll) (i: Z) (x: Z) (PreH1 : (1 <= n_pre)) (PreH2 : (n_pre <= stack_capacity)) (PreH3 : (1 <= i)) (PreH4 : (i < n_pre)) (PreH5 : (x = (Znth i input 0))) (PreH6 : ((Zlength (input)) = n_pre)) (PreH7 : (BuildStackPrefix prefix input i )) ,
  (store_stack stack_pre (sll_cons (x) (prefix)) (i + 1 ) )
  **  (IntArray.seg stack_pre (i + 1 ) n_pre (sublist ((i + 1 )) (n_pre) (input)) )
|--
  EX (next: sll) ,
  “ (1 <= n_pre) ” 
  &&  “ (n_pre <= stack_capacity) ” 
  &&  “ (1 <= i) ” 
  &&  “ (i < n_pre) ” 
  &&  “ (x = (Znth i input 0)) ” 
  &&  “ ((Zlength (input)) = n_pre) ” 
  &&  “ (BuildStackPrefix next input (i + 1 ) ) ”
  &&  (store_stack stack_pre next (i + 1 ) )
  **  (IntArray.seg stack_pre (i + 1 ) n_pre (sublist ((i + 1 )) (n_pre) (input)) )
) \/
(
forall (n_pre: Z) (input: (@list Z)) (prefix: sll) (i: Z) (x: Z) (PreH1 : (1 <= n_pre)) (PreH2 : (n_pre <= stack_capacity)) (PreH3 : (1 <= i)) (PreH4 : (i < n_pre)) (PreH5 : (x = (Znth i input 0))) (PreH6 : ((Zlength (input)) = n_pre)) (PreH7 : (BuildStackPrefix prefix input i )) ,
  TT && emp 
|--
  “ (BuildStackPrefix (sll_cons (x) (prefix)) input (i + 1 ) ) ”
  &&  emp
).

Definition build_entail_wit_3_split_goal_1 := 
forall (n_pre: Z) (input: (@list Z)) (prefix: sll) (i: Z) (x: Z) (PreH1 : (1 <= n_pre)) (PreH2 : (n_pre <= stack_capacity)) (PreH3 : (1 <= i)) (PreH4 : (i < n_pre)) (PreH5 : (x = (Znth i input 0))) (PreH6 : ((Zlength (input)) = n_pre)) (PreH7 : (BuildStackPrefix prefix input i )) ,
  (BuildStackPrefix (sll_cons (x) (prefix)) input (i + 1 ) )
.

Definition build_entail_wit_4 := 
forall (n_pre: Z) (stack_pre: Z) (input: (@list Z)) (next: sll) (i: Z) (x: Z) (PreH1 : (1 <= n_pre)) (PreH2 : (n_pre <= stack_capacity)) (PreH3 : (1 <= i)) (PreH4 : (i < n_pre)) (PreH5 : (x = (Znth i input 0))) (PreH6 : ((Zlength (input)) = n_pre)) (PreH7 : (BuildStackPrefix next input (i + 1 ) )) ,
  (store_stack stack_pre next (i + 1 ) )
  **  (IntArray.seg stack_pre (i + 1 ) n_pre (sublist ((i + 1 )) (n_pre) (input)) )
|--
  EX (prefix: sll) ,
  “ (1 <= n_pre) ” 
  &&  “ (n_pre <= stack_capacity) ” 
  &&  “ (1 <= (i + 1 )) ” 
  &&  “ ((i + 1 ) <= n_pre) ” 
  &&  “ ((Zlength (input)) = n_pre) ” 
  &&  “ (BuildStackPrefix prefix input (i + 1 ) ) ”
  &&  (store_stack stack_pre prefix (i + 1 ) )
  **  (IntArray.seg stack_pre (i + 1 ) n_pre (sublist ((i + 1 )) (n_pre) (input)) )
.

Definition build_entail_wit_5_1 := 
(
forall (n_pre: Z) (stack_pre: Z) (input: (@list Z)) (i: Z) (PreH1 : (i >= n_pre)) (PreH2 : (n_pre = 0)) (PreH3 : (i = 1)) (PreH4 : ((Zlength (input)) = n_pre)) ,
  (IntArray.full stack_pre n_pre input )
|--
  “ (0 <= n_pre) ” 
  &&  “ (n_pre <= stack_capacity) ” 
  &&  “ ((Zlength (input)) = n_pre) ”
  &&  (store_stack stack_pre (sll_from_array (input)) n_pre )
) \/
(
forall (n_pre: Z) (stack_pre: Z) (input: (@list Z)) (i: Z) (PreH1 : (i >= n_pre)) (PreH2 : (n_pre = 0)) (PreH3 : (i = 1)) (PreH4 : ((Zlength (input)) = n_pre)) ,
  (IntArray.full stack_pre n_pre input )
|--
  “ (0 <= stack_capacity) ”
  &&  (store_stack stack_pre (sll_from_array (input)) n_pre )
).

Definition build_entail_wit_5_1_split_goal_1 := 
forall (n_pre: Z) (stack_pre: Z) (input: (@list Z)) (i: Z) (PreH1 : (i >= n_pre)) (PreH2 : (n_pre = 0)) (PreH3 : (i = 1)) (PreH4 : ((Zlength (input)) = n_pre)) ,
  (IntArray.full stack_pre n_pre input )
|--
  “ (0 <= stack_capacity) ”
.

Definition build_entail_wit_5_1_split_goal_spatial := 
forall (n_pre: Z) (stack_pre: Z) (input: (@list Z)) (i: Z) (PreH1 : (i >= n_pre)) (PreH2 : (n_pre = 0)) (PreH3 : (i = 1)) (PreH4 : ((Zlength (input)) = n_pre)) ,
  (IntArray.full stack_pre n_pre input )
|--
  (store_stack stack_pre (sll_from_array (input)) n_pre )
.

Definition build_entail_wit_5_2 := 
(
forall (n_pre: Z) (stack_pre: Z) (input: (@list Z)) (prefix: sll) (i: Z) (PreH1 : (i >= n_pre)) (PreH2 : (1 <= n_pre)) (PreH3 : (n_pre <= stack_capacity)) (PreH4 : (1 <= i)) (PreH5 : (i <= n_pre)) (PreH6 : ((Zlength (input)) = n_pre)) (PreH7 : (BuildStackPrefix prefix input i )) ,
  (store_stack stack_pre prefix i )
  **  (IntArray.seg stack_pre i n_pre (sublist (i) (n_pre) (input)) )
|--
  “ (0 <= n_pre) ” 
  &&  “ (n_pre <= stack_capacity) ” 
  &&  “ ((Zlength (input)) = n_pre) ”
  &&  (store_stack stack_pre (sll_from_array (input)) n_pre )
) \/
(
forall (n_pre: Z) (stack_pre: Z) (input: (@list Z)) (prefix: sll) (i: Z) (PreH1 : (i >= n_pre)) (PreH2 : (1 <= n_pre)) (PreH3 : (n_pre <= stack_capacity)) (PreH4 : (1 <= i)) (PreH5 : (i <= n_pre)) (PreH6 : ((Zlength (input)) = n_pre)) (PreH7 : (BuildStackPrefix prefix input i )) ,
  (store_stack stack_pre prefix i )
  **  (IntArray.seg stack_pre i n_pre (sublist (i) (n_pre) (input)) )
|--
  (store_stack stack_pre (sll_from_array (input)) n_pre )
).

Definition build_entail_wit_5_2_split_goal_spatial := 
forall (n_pre: Z) (stack_pre: Z) (input: (@list Z)) (prefix: sll) (i: Z) (PreH1 : (i >= n_pre)) (PreH2 : (1 <= n_pre)) (PreH3 : (n_pre <= stack_capacity)) (PreH4 : (1 <= i)) (PreH5 : (i <= n_pre)) (PreH6 : ((Zlength (input)) = n_pre)) (PreH7 : (BuildStackPrefix prefix input i )) ,
  (store_stack stack_pre prefix i )
  **  (IntArray.seg stack_pre i n_pre (sublist (i) (n_pre) (input)) )
|--
  (store_stack stack_pre (sll_from_array (input)) n_pre )
.

Definition build_return_wit_1 := 
forall (n_pre: Z) (stack_pre: Z) (input: (@list Z)) (PreH1 : (0 <= n_pre)) (PreH2 : (n_pre <= stack_capacity)) (PreH3 : ((Zlength (input)) = n_pre)) ,
  (store_stack stack_pre (sll_from_array (input)) n_pre )
|--
  (store_stack stack_pre (sll_from_array (input)) n_pre )
.

Definition build_partial_solve_wit_1 := 
forall (n_pre: Z) (stack_pre: Z) (input: (@list Z)) (prefix: sll) (i: Z) (PreH1 : (i < n_pre)) (PreH2 : (1 <= n_pre)) (PreH3 : (n_pre <= stack_capacity)) (PreH4 : (1 <= i)) (PreH5 : (i <= n_pre)) (PreH6 : ((Zlength (input)) = n_pre)) (PreH7 : (BuildStackPrefix prefix input i )) ,
  (store_stack stack_pre prefix i )
  **  (IntArray.seg stack_pre i n_pre (sublist (i) (n_pre) (input)) )
|--
  “ (i < n_pre) ” 
  &&  “ (1 <= n_pre) ” 
  &&  “ (n_pre <= stack_capacity) ” 
  &&  “ (1 <= i) ” 
  &&  “ (i <= n_pre) ” 
  &&  “ ((Zlength (input)) = n_pre) ” 
  &&  “ (BuildStackPrefix prefix input i ) ”
  &&  (((stack_pre + (i * sizeof(INT)))) # Int  |-> (Znth (i - i ) (sublist (i) (n_pre) (input)) 0))
  **  (IntArray.missing_i stack_pre i i n_pre (sublist (i) (n_pre) (input)) )
  **  (store_stack stack_pre prefix i )
.

Definition build_partial_solve_wit_2_pure := 
forall (n_pre: Z) (stack_pre: Z) (input: (@list Z)) (prefix: sll) (i: Z) (x: Z) (PreH1 : (1 <= n_pre)) (PreH2 : (n_pre <= stack_capacity)) (PreH3 : (1 <= i)) (PreH4 : (i < n_pre)) (PreH5 : (x = (Znth i input 0))) (PreH6 : ((Zlength (input)) = n_pre)) (PreH7 : (BuildStackPrefix prefix input i )) ,
  ((( &( "stack" ) )) # Ptr  |-> stack_pre)
  **  ((( &( "n" ) )) # Int  |-> n_pre)
  **  ((( &( "i" ) )) # Int  |-> i)
  **  ((( &( "x" ) )) # Int  |-> x)
  **  (store_stack stack_pre prefix i )
  **  (IntArray.undef_seg stack_pre i (i + 1 ) )
  **  (IntArray.seg stack_pre (i + 1 ) n_pre (sublist ((i + 1 )) (n_pre) (input)) )
|--
  “ (i < stack_capacity) ”
.

Definition build_partial_solve_wit_2_aux := 
forall (n_pre: Z) (stack_pre: Z) (input: (@list Z)) (prefix: sll) (i: Z) (x: Z) (PreH1 : (1 <= n_pre)) (PreH2 : (n_pre <= stack_capacity)) (PreH3 : (1 <= i)) (PreH4 : (i < n_pre)) (PreH5 : (x = (Znth i input 0))) (PreH6 : ((Zlength (input)) = n_pre)) (PreH7 : (BuildStackPrefix prefix input i )) ,
  (store_stack stack_pre prefix i )
  **  (IntArray.undef_seg stack_pre i (i + 1 ) )
  **  (IntArray.seg stack_pre (i + 1 ) n_pre (sublist ((i + 1 )) (n_pre) (input)) )
|--
  “ (i < stack_capacity) ” 
  &&  “ (1 <= n_pre) ” 
  &&  “ (n_pre <= stack_capacity) ” 
  &&  “ (1 <= i) ” 
  &&  “ (i < n_pre) ” 
  &&  “ (x = (Znth i input 0)) ” 
  &&  “ ((Zlength (input)) = n_pre) ” 
  &&  “ (BuildStackPrefix prefix input i ) ”
  &&  (store_stack stack_pre prefix i )
  **  (IntArray.undef_seg stack_pre i (i + 1 ) )
  **  (IntArray.seg stack_pre (i + 1 ) n_pre (sublist ((i + 1 )) (n_pre) (input)) )
.

Definition build_partial_solve_wit_2 := build_partial_solve_wit_2_pure -> build_partial_solve_wit_2_aux.

Module Type VC_Correct.


Axiom proof_of_push_entail_wit_1 : push_entail_wit_1.
Axiom proof_of_push_entail_wit_2 : push_entail_wit_2.
Axiom proof_of_push_return_wit_1 : push_return_wit_1.
Axiom proof_of_push_partial_solve_wit_1 : push_partial_solve_wit_1.
Axiom proof_of_pop_safety_wit_1 : pop_safety_wit_1.
Axiom proof_of_pop_safety_wit_2 : pop_safety_wit_2.
Axiom proof_of_pop_entail_wit_1 : pop_entail_wit_1.
Axiom proof_of_pop_entail_wit_2 : pop_entail_wit_2.
Axiom proof_of_pop_return_wit_1 : pop_return_wit_1.
Axiom proof_of_pop_partial_solve_wit_1 : pop_partial_solve_wit_1.
Axiom proof_of_build_safety_wit_1 : build_safety_wit_1.
Axiom proof_of_build_safety_wit_2 : build_safety_wit_2.
Axiom proof_of_build_safety_wit_3 : build_safety_wit_3.
Axiom proof_of_build_entail_wit_1 : build_entail_wit_1.
Axiom proof_of_build_entail_wit_2 : build_entail_wit_2.
Axiom proof_of_build_entail_wit_3 : build_entail_wit_3.
Axiom proof_of_build_entail_wit_4 : build_entail_wit_4.
Axiom proof_of_build_entail_wit_5_1 : build_entail_wit_5_1.
Axiom proof_of_build_entail_wit_5_2 : build_entail_wit_5_2.
Axiom proof_of_build_return_wit_1 : build_return_wit_1.
Axiom proof_of_build_partial_solve_wit_1 : build_partial_solve_wit_1.
Axiom proof_of_build_partial_solve_wit_2_pure : build_partial_solve_wit_2_pure.
Axiom proof_of_build_partial_solve_wit_2 : build_partial_solve_wit_2.

End VC_Correct.