-
Notifications
You must be signed in to change notification settings - Fork 87
Expand file tree
/
Copy pathsparse_array.coma
More file actions
1572 lines (1147 loc) · 66.3 KB
/
Copy pathsparse_array.coma
File metadata and controls
1572 lines (1147 loc) · 66.3 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
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
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
module M_create
use creusot.int.UInt64
use creusot.slice.Slice64
use creusot.prelude.Any
use seq.Seq
use int.Int
type t_T
constant const_SIZE : UInt64.t
type t_Sparse_T = {
n: UInt64.t;
values: Slice64.array t_T;
idx: Slice64.array UInt64.t;
back: Slice64.array UInt64.t }
predicate inv_T (_1: t_T)
function index_array_usize_n [@inline:trivial] (self: Slice64.array UInt64.t) (ix: int) : UInt64.t =
Seq.get (Slice64.view self) ix
meta "rewrite_def" function index_array_usize_n
predicate invariant_Sparse_T (self: t_Sparse_T) =
UInt64.t'int self.n <= UInt64.t'int const_SIZE
/\ (forall i: int. 0 <= i /\ i < UInt64.t'int self.n
-> (let j = index_array_usize_n self.back i in 0 <= UInt64.t'int j
/\ UInt64.t'int j < UInt64.t'int const_SIZE /\ UInt64.t'int (index_array_usize_n self.idx (UInt64.t'int j)) = i))
predicate invariant_ref_T [@inline:trivial] (self: t_T) = inv_T self
meta "rewrite_def" predicate invariant_ref_T
predicate inv_ref_T [@inline:trivial] (_1: t_T) = invariant_ref_T _1
meta "rewrite_def" predicate inv_ref_T
predicate invariant_Seq_T [@inline:trivial] (self: Seq.seq t_T) =
forall i: int. 0 <= i /\ i < Seq.length self -> inv_ref_T (Seq.get self i)
meta "rewrite_def" predicate invariant_Seq_T
predicate inv_Seq_T [@inline:trivial] (_1: Seq.seq t_T) = invariant_Seq_T _1
meta "rewrite_def" predicate inv_Seq_T
predicate invariant_array_T_n (self: Slice64.array t_T) =
inv_Seq_T (Slice64.view self) /\ Seq.length (Slice64.view self) = UInt64.t'int const_SIZE
predicate inv_array_T_n [@inline:trivial] (_1: Slice64.array t_T) = invariant_array_T_n _1
meta "rewrite_def" predicate inv_array_T_n
predicate inv_Seq_usize [@inline:trivial] (_1: Seq.seq UInt64.t) = true
meta "rewrite_def" predicate inv_Seq_usize
predicate invariant_array_usize_n (self: Slice64.array UInt64.t) =
inv_Seq_usize (Slice64.view self) /\ Seq.length (Slice64.view self) = UInt64.t'int const_SIZE
predicate inv_array_usize_n [@inline:trivial] (_1: Slice64.array UInt64.t) = invariant_array_usize_n _1
meta "rewrite_def" predicate inv_array_usize_n
predicate inv_Sparse_T (_1: t_Sparse_T)
axiom inv_axiom [@rewrite]: forall x: t_Sparse_T [inv_Sparse_T x]. inv_Sparse_T x
= (invariant_Sparse_T x /\ inv_array_T_n x.values /\ inv_array_usize_n x.idx /\ inv_array_usize_n x.back)
type t_Option_T = None | Some t_T
predicate is_elt_T (self: t_Sparse_T) (i: int) =
UInt64.t'int (index_array_usize_n self.idx i) < UInt64.t'int self.n
/\ UInt64.t'int (index_array_usize_n self.back (UInt64.t'int (index_array_usize_n self.idx i))) = i
function index_array_T_n [@inline:trivial] (self: Slice64.array t_T) (ix: int) : t_T = Seq.get (Slice64.view self) ix
meta "rewrite_def" function index_array_T_n
function view_Sparse_T (self: t_Sparse_T) : Seq.seq t_Option_T =
Seq.create (UInt64.t'int const_SIZE) (fun (i: int) -> if is_elt_T self i then
Some (index_array_T_n self.values i)
else
None
)
axiom view_Sparse_T_spec: forall self: t_Sparse_T [view_Sparse_T self]. Seq.length (view_Sparse_T self)
= UInt64.t'int const_SIZE
meta "compute_max_steps" 1000000
meta "select_lsinst" "all"
let create_T (dummy: t_T) (return (x: t_Sparse_T)) = {[@stop_split] [@expl:create 'dummy' type invariant] inv_T dummy}
(! bb0
[ bb0 = s0
[ s0 = Slice64.create <t_T> {const_SIZE} {fun (_: int) -> dummy}
(fun (_res: Slice64.array t_T) -> [ &_3 <- _res ] s1)
| s1 = Slice64.create <UInt64.t> {const_SIZE} {fun (_: int) -> (0: UInt64.t)}
(fun (_res: Slice64.array UInt64.t) -> [ &_5 <- _res ] s2)
| s2 = Slice64.create <UInt64.t> {const_SIZE} {fun (_: int) -> (0: UInt64.t)}
(fun (_res: Slice64.array UInt64.t) -> [ &_6 <- _res ] s3)
| s3 = [ &_ret <- { n = (0: UInt64.t); values = _3; idx = _5; back = _6 } ] s4
| s4 = return {_ret} ] ]
[ & _ret: t_Sparse_T = Any.any_l ()
| & dummy: t_T = dummy
| & _3: Slice64.array t_T = Any.any_l ()
| & _5: Slice64.array UInt64.t = Any.any_l ()
| & _6: Slice64.array UInt64.t = Any.any_l () ])
[ return (result: t_Sparse_T) ->
{[@stop_split] [@expl:create_T ensures] ([@stop_split] [@expl:create result type invariant] inv_Sparse_T result)
/\ ([@stop_split] [@expl:create ensures] forall i: int. 0 <= i /\ i < UInt64.t'int const_SIZE
-> Seq.get (view_Sparse_T result) i = None)}
(! return {result}) ]
end
module M_f
use creusot.int.Int32
use creusot.int.UInt64
use creusot.slice.Slice64
use seq.Seq
use creusot.prelude.MutBorrow
use creusot.prelude.Any
use int.Int
type t_Sparse_i32 = {
n: UInt64.t;
values: Slice64.array Int32.t;
idx: Slice64.array UInt64.t;
back: Slice64.array UInt64.t }
function index_array_usize_10 [@inline:trivial] (self: Slice64.array UInt64.t) (ix: int) : UInt64.t =
Seq.get (Slice64.view self) ix
meta "rewrite_def" function index_array_usize_10
predicate invariant_Sparse_i32 (self: t_Sparse_i32) =
UInt64.t'int self.n <= UInt64.t'int (10: UInt64.t)
/\ (forall i: int. 0 <= i /\ i < UInt64.t'int self.n
-> (let j = index_array_usize_10 self.back i in 0 <= UInt64.t'int j
/\ UInt64.t'int j < UInt64.t'int (10: UInt64.t)
/\ UInt64.t'int (index_array_usize_10 self.idx (UInt64.t'int j)) = i))
predicate inv_Seq_i32 [@inline:trivial] (_1: Seq.seq Int32.t) = true
meta "rewrite_def" predicate inv_Seq_i32
predicate invariant_array_i32_10 (self: Slice64.array Int32.t) =
inv_Seq_i32 (Slice64.view self) /\ Seq.length (Slice64.view self) = UInt64.t'int (10: UInt64.t)
predicate inv_array_i32_10 [@inline:trivial] (_1: Slice64.array Int32.t) = invariant_array_i32_10 _1
meta "rewrite_def" predicate inv_array_i32_10
predicate inv_Seq_usize [@inline:trivial] (_1: Seq.seq UInt64.t) = true
meta "rewrite_def" predicate inv_Seq_usize
predicate invariant_array_usize_10 (self: Slice64.array UInt64.t) =
inv_Seq_usize (Slice64.view self) /\ Seq.length (Slice64.view self) = UInt64.t'int (10: UInt64.t)
predicate inv_array_usize_10 [@inline:trivial] (_1: Slice64.array UInt64.t) = invariant_array_usize_10 _1
meta "rewrite_def" predicate inv_array_usize_10
predicate inv_Sparse_i32 (_1: t_Sparse_i32)
axiom inv_axiom [@rewrite]: forall x: t_Sparse_i32 [inv_Sparse_i32 x]. inv_Sparse_i32 x
= (invariant_Sparse_i32 x /\ inv_array_i32_10 x.values /\ inv_array_usize_10 x.idx /\ inv_array_usize_10 x.back)
type t_Option_i32 = None | Some Int32.t
predicate is_elt_i32 (self: t_Sparse_i32) (i: int) =
UInt64.t'int (index_array_usize_10 self.idx i) < UInt64.t'int self.n
/\ UInt64.t'int (index_array_usize_10 self.back (UInt64.t'int (index_array_usize_10 self.idx i))) = i
function index_array_i32_10 [@inline:trivial] (self: Slice64.array Int32.t) (ix: int) : Int32.t =
Seq.get (Slice64.view self) ix
meta "rewrite_def" function index_array_i32_10
function view_Sparse_i32 (self: t_Sparse_i32) : Seq.seq t_Option_i32 =
Seq.create (UInt64.t'int (10: UInt64.t)) (fun (i: int) -> if is_elt_i32 self i then
Some (index_array_i32_10 self.values i)
else
None
)
axiom view_Sparse_i32_spec: forall self: t_Sparse_i32 [view_Sparse_i32 self]. Seq.length (view_Sparse_i32 self)
= UInt64.t'int (10: UInt64.t)
let create_i32 (dummy: Int32.t) (return (x: t_Sparse_i32)) = any
[ return (result: t_Sparse_i32) ->
{[@stop_split] [@expl:create_i32 ensures] ([@stop_split] [@expl:create result type invariant] inv_Sparse_i32 result)
/\ ([@stop_split] [@expl:create ensures] forall i: int. 0 <= i /\ i < UInt64.t'int (10: UInt64.t)
-> Seq.get (view_Sparse_i32 result) i = None)}
(! return {result}) ]
type t_Sparse_i32'0 = {
n'0: UInt64.t;
values'0: Slice64.array Int32.t;
idx'0: Slice64.array UInt64.t;
back'0: Slice64.array UInt64.t }
function index_array_usize_20 [@inline:trivial] (self: Slice64.array UInt64.t) (ix: int) : UInt64.t =
Seq.get (Slice64.view self) ix
meta "rewrite_def" function index_array_usize_20
predicate invariant_Sparse_i32'0 (self: t_Sparse_i32'0) =
UInt64.t'int self.n'0 <= UInt64.t'int (20: UInt64.t)
/\ (forall i: int. 0 <= i /\ i < UInt64.t'int self.n'0
-> (let j = index_array_usize_20 self.back'0 i in 0 <= UInt64.t'int j
/\ UInt64.t'int j < UInt64.t'int (20: UInt64.t)
/\ UInt64.t'int (index_array_usize_20 self.idx'0 (UInt64.t'int j)) = i))
predicate invariant_array_i32_20 (self: Slice64.array Int32.t) =
inv_Seq_i32 (Slice64.view self) /\ Seq.length (Slice64.view self) = UInt64.t'int (20: UInt64.t)
predicate inv_array_i32_20 [@inline:trivial] (_1: Slice64.array Int32.t) = invariant_array_i32_20 _1
meta "rewrite_def" predicate inv_array_i32_20
predicate invariant_array_usize_20 (self: Slice64.array UInt64.t) =
inv_Seq_usize (Slice64.view self) /\ Seq.length (Slice64.view self) = UInt64.t'int (20: UInt64.t)
predicate inv_array_usize_20 [@inline:trivial] (_1: Slice64.array UInt64.t) = invariant_array_usize_20 _1
meta "rewrite_def" predicate inv_array_usize_20
predicate inv_Sparse_i32'0 (_1: t_Sparse_i32'0)
axiom inv_axiom'0 [@rewrite]: forall x: t_Sparse_i32'0 [inv_Sparse_i32'0 x]. inv_Sparse_i32'0 x
= (invariant_Sparse_i32'0 x
/\ inv_array_i32_20 x.values'0 /\ inv_array_usize_20 x.idx'0 /\ inv_array_usize_20 x.back'0)
predicate is_elt_i32'0 (self: t_Sparse_i32'0) (i: int) =
UInt64.t'int (index_array_usize_20 self.idx'0 i) < UInt64.t'int self.n'0
/\ UInt64.t'int (index_array_usize_20 self.back'0 (UInt64.t'int (index_array_usize_20 self.idx'0 i))) = i
function index_array_i32_20 [@inline:trivial] (self: Slice64.array Int32.t) (ix: int) : Int32.t =
Seq.get (Slice64.view self) ix
meta "rewrite_def" function index_array_i32_20
function view_Sparse_i32'0 (self: t_Sparse_i32'0) : Seq.seq t_Option_i32 =
Seq.create (UInt64.t'int (20: UInt64.t)) (fun (i: int) -> if is_elt_i32'0 self i then
Some (index_array_i32_20 self.values'0 i)
else
None
)
axiom view_Sparse_i32_spec'0:
forall self: t_Sparse_i32'0 [view_Sparse_i32'0 self]. Seq.length (view_Sparse_i32'0 self)
= UInt64.t'int (20: UInt64.t)
let create_i32'0 (dummy: Int32.t) (return (x: t_Sparse_i32'0)) = any
[ return (result: t_Sparse_i32'0) ->
{[@stop_split] [@expl:create_i32 ensures] ([@stop_split] [@expl:create result type invariant] inv_Sparse_i32'0 result)
/\ ([@stop_split] [@expl:create ensures] forall i: int. 0 <= i /\ i < UInt64.t'int (20: UInt64.t)
-> Seq.get (view_Sparse_i32'0 result) i = None)}
(! return {result}) ]
type t_Option_ref_i32 = None'0 | Some'0 Int32.t
predicate invariant_ref_Sparse_i32 [@inline:trivial] (self: t_Sparse_i32) = inv_Sparse_i32 self
meta "rewrite_def" predicate invariant_ref_Sparse_i32
predicate inv_ref_Sparse_i32 [@inline:trivial] (_1: t_Sparse_i32) = invariant_ref_Sparse_i32 _1
meta "rewrite_def" predicate inv_ref_Sparse_i32
let get_i32 (self: t_Sparse_i32) (i: UInt64.t) (return (x: t_Option_ref_i32)) =
{[@stop_split] [@expl:get_i32 requires] ([@stop_split] [@expl:get 'self' type invariant] inv_ref_Sparse_i32 self)
/\ ([@stop_split] [@expl:get requires] UInt64.t'int i < UInt64.t'int (10: UInt64.t))}
any
[ return (result: t_Option_ref_i32) ->
{[@stop_split] [@expl:get_i32 ensures] ([@stop_split] [@expl:get ensures #0] match result with
| None'0 -> Seq.get (view_Sparse_i32 self) (UInt64.t'int i) = None
| Some'0 x -> Seq.get (view_Sparse_i32 self) (UInt64.t'int i) = Some x
end)
/\ ([@stop_split] [@expl:get ensures #1] match Seq.get (view_Sparse_i32 self) (UInt64.t'int i) with
| None -> result = None'0
| Some _ -> true
end)}
(! return {result}) ]
predicate invariant_ref_Sparse_i32'0 [@inline:trivial] (self: t_Sparse_i32'0) = inv_Sparse_i32'0 self
meta "rewrite_def" predicate invariant_ref_Sparse_i32'0
predicate inv_ref_Sparse_i32'0 [@inline:trivial] (_1: t_Sparse_i32'0) = invariant_ref_Sparse_i32'0 _1
meta "rewrite_def" predicate inv_ref_Sparse_i32'0
let get_i32'0 (self: t_Sparse_i32'0) (i: UInt64.t) (return (x: t_Option_ref_i32)) =
{[@stop_split] [@expl:get_i32 requires] ([@stop_split] [@expl:get 'self' type invariant] inv_ref_Sparse_i32'0 self)
/\ ([@stop_split] [@expl:get requires] UInt64.t'int i < UInt64.t'int (20: UInt64.t))}
any
[ return (result: t_Option_ref_i32) ->
{[@stop_split] [@expl:get_i32 ensures] ([@stop_split] [@expl:get ensures #0] match result with
| None'0 -> Seq.get (view_Sparse_i32'0 self) (UInt64.t'int i) = None
| Some'0 x -> Seq.get (view_Sparse_i32'0 self) (UInt64.t'int i) = Some x
end)
/\ ([@stop_split] [@expl:get ensures #1] match Seq.get (view_Sparse_i32'0 self) (UInt64.t'int i) with
| None -> result = None'0
| Some _ -> true
end)}
(! return {result}) ]
predicate invariant_refmut_Sparse_i32 [@inline:trivial] (self: MutBorrow.t t_Sparse_i32) =
inv_Sparse_i32 self.current /\ inv_Sparse_i32 self.final
meta "rewrite_def" predicate invariant_refmut_Sparse_i32
predicate inv_refmut_Sparse_i32 [@inline:trivial] (_1: MutBorrow.t t_Sparse_i32) = invariant_refmut_Sparse_i32 _1
meta "rewrite_def" predicate inv_refmut_Sparse_i32
let set_i32 (self: MutBorrow.t t_Sparse_i32) (i: UInt64.t) (v: Int32.t) (return (x: ())) =
{[@stop_split] [@expl:set_i32 requires] ([@stop_split] [@expl:set 'self' type invariant] inv_refmut_Sparse_i32 self)
/\ ([@stop_split] [@expl:set requires] UInt64.t'int i < UInt64.t'int (10: UInt64.t))}
any
[ return (result: ()) ->
{[@stop_split] [@expl:set_i32 ensures] ([@stop_split] [@expl:set ensures #0] forall j: int. 0 <= j
/\ j < UInt64.t'int (10: UInt64.t) /\ j <> UInt64.t'int i
-> Seq.get (view_Sparse_i32 self.final) j = Seq.get (view_Sparse_i32 self.current) j)
/\ ([@stop_split] [@expl:set ensures #1] Seq.get (view_Sparse_i32 self.final) (UInt64.t'int i) = Some v)}
(! return {result}) ]
predicate invariant_refmut_Sparse_i32'0 [@inline:trivial] (self: MutBorrow.t t_Sparse_i32'0) =
inv_Sparse_i32'0 self.current /\ inv_Sparse_i32'0 self.final
meta "rewrite_def" predicate invariant_refmut_Sparse_i32'0
predicate inv_refmut_Sparse_i32'0 [@inline:trivial] (_1: MutBorrow.t t_Sparse_i32'0) =
invariant_refmut_Sparse_i32'0 _1
meta "rewrite_def" predicate inv_refmut_Sparse_i32'0
let set_i32'0 (self: MutBorrow.t t_Sparse_i32'0) (i: UInt64.t) (v: Int32.t) (return (x: ())) =
{[@stop_split] [@expl:set_i32 requires] ([@stop_split] [@expl:set 'self' type invariant] inv_refmut_Sparse_i32'0 self)
/\ ([@stop_split] [@expl:set requires] UInt64.t'int i < UInt64.t'int (20: UInt64.t))}
any
[ return (result: ()) ->
{[@stop_split] [@expl:set_i32 ensures] ([@stop_split] [@expl:set ensures #0] forall j: int. 0 <= j
/\ j < UInt64.t'int (20: UInt64.t) /\ j <> UInt64.t'int i
-> Seq.get (view_Sparse_i32'0 self.final) j = Seq.get (view_Sparse_i32'0 self.current) j)
/\ ([@stop_split] [@expl:set ensures #1] Seq.get (view_Sparse_i32'0 self.final) (UInt64.t'int i) = Some v)}
(! return {result}) ]
predicate resolve_Option_i32 [@inline:trivial] (_1: t_Option_i32) = true
meta "rewrite_def" predicate resolve_Option_i32
predicate resolve_Sparse_i32 (self: t_Sparse_i32) =
forall i: int. 0 <= i /\ i < UInt64.t'int (10: UInt64.t) -> resolve_Option_i32 (Seq.get (view_Sparse_i32 self) i)
predicate resolve_Sparse_i32'0 (_1: t_Sparse_i32)
axiom resolve_axiom [@rewrite]: forall x: t_Sparse_i32 [resolve_Sparse_i32'0 x]. resolve_Sparse_i32'0 x
= resolve_Sparse_i32 x
predicate resolve_Sparse_i32'1 (self: t_Sparse_i32'0) =
forall i: int. 0 <= i /\ i < UInt64.t'int (20: UInt64.t) -> resolve_Option_i32 (Seq.get (view_Sparse_i32'0 self) i)
predicate resolve_Sparse_i32'2 (_1: t_Sparse_i32'0)
axiom resolve_axiom'0 [@rewrite]: forall x: t_Sparse_i32'0 [resolve_Sparse_i32'2 x]. resolve_Sparse_i32'2 x
= resolve_Sparse_i32'1 x
meta "compute_max_steps" 1000000
meta "select_lsinst" "all"
let f (return (x: ())) = (! bb0
[ bb0 = s0
[ s0 = [ &default <- (0: Int32.t) ] s1
| s1 = create_i32 {default} (fun (_x: t_Sparse_i32) -> [ &a <- _x ] s2)
| s2 = create_i32'0 {default} (fun (_x: t_Sparse_i32'0) -> [ &b <- _x ] s3)
| s3 = get_i32 {a} {(5: UInt64.t)} (fun (_x: t_Option_ref_i32) -> [ &x <- _x ] s4)
| s4 = get_i32'0 {b} {(7: UInt64.t)} (fun (_x: t_Option_ref_i32) -> [ &y <- _x ] s5)
| s5 = {[@expl:assertion] x = None'0 /\ y = None'0} s6
| s6 = MutBorrow.borrow_mut <t_Sparse_i32> {a}
(fun (_bor: MutBorrow.t t_Sparse_i32) ->
[ &_15 <- _bor ] -{inv_Sparse_i32 _bor.final}-
[ &a <- _bor.final ] s7) [ _ck -> (! {[@expl:type invariant] inv_Sparse_i32 a} any) ]
| s7 = set_i32 {_15} {(5: UInt64.t)} {(1: Int32.t)} (fun (_x: ()) -> [ &_14 <- _x ] s8)
| s8 = MutBorrow.borrow_mut <t_Sparse_i32'0> {b}
(fun (_bor: MutBorrow.t t_Sparse_i32'0) ->
[ &_17 <- _bor ] -{inv_Sparse_i32'0 _bor.final}-
[ &b <- _bor.final ] s9) [ _ck -> (! {[@expl:type invariant] inv_Sparse_i32'0 b} any) ]
| s9 = set_i32'0 {_17} {(7: UInt64.t)} {(2: Int32.t)} (fun (_x: ()) -> [ &_16 <- _x ] s10)
| s10 = get_i32 {a} {(5: UInt64.t)} (fun (_x: t_Option_ref_i32) -> [ &_18 <- _x ] s11)
| s11 = [ &x <- _18 ] s12
| s12 = get_i32'0 {b} {(7: UInt64.t)} (fun (_x: t_Option_ref_i32) -> [ &_20 <- _x ] s13)
| s13 = [ &y <- _20 ] s14
| s14 = {[@expl:assertion] match x with
| None'0 -> false
| Some'0 z -> Int32.to_int z = 1
end}
s15
| s15 = {[@expl:assertion] match y with
| None'0 -> false
| Some'0 z -> Int32.to_int z = 2
end}
s16
| s16 = get_i32 {a} {(7: UInt64.t)} (fun (_x: t_Option_ref_i32) -> [ &_28 <- _x ] s17)
| s17 = [ &x <- _28 ] s18
| s18 = get_i32'0 {b} {(5: UInt64.t)} (fun (_x: t_Option_ref_i32) -> [ &_30 <- _x ] s19)
| s19 = [ &y <- _30 ] s20
| s20 = {[@expl:assertion] x = None'0 /\ y = None'0} s21
| s21 = get_i32 {a} {(0: UInt64.t)} (fun (_x: t_Option_ref_i32) -> [ &_36 <- _x ] s22)
| s22 = [ &x <- _36 ] s23
| s23 = get_i32'0 {b} {(0: UInt64.t)} (fun (_x: t_Option_ref_i32) -> [ &_38 <- _x ] s24)
| s24 = [ &y <- _38 ] s25
| s25 = {[@expl:assertion] x = None'0 /\ y = None'0} s26
| s26 = s27 [ _ck -> (! {[@expl:type invariant] inv_Sparse_i32 a} any) ]
| s27 = -{resolve_Sparse_i32'0 a}- s28
| s28 = get_i32 {a} {(9: UInt64.t)} (fun (_x: t_Option_ref_i32) -> [ &_44 <- _x ] s29)
| s29 = [ &x <- _44 ] s30
| s30 = s31 [ _ck -> (! {[@expl:type invariant] inv_Sparse_i32'0 b} any) ]
| s31 = -{resolve_Sparse_i32'2 b}- s32
| s32 = get_i32'0 {b} {(9: UInt64.t)} (fun (_x: t_Option_ref_i32) -> [ &_46 <- _x ] s33)
| s33 = [ &y <- _46 ] s34
| s34 = {[@expl:assertion] x = None'0 /\ y = None'0} s35
| s35 = return {_ret} ] ]
[ & _ret: () = Any.any_l ()
| & default: Int32.t = Any.any_l ()
| & a: t_Sparse_i32 = Any.any_l ()
| & b: t_Sparse_i32'0 = Any.any_l ()
| & x: t_Option_ref_i32 = Any.any_l ()
| & y: t_Option_ref_i32 = Any.any_l ()
| & _14: () = Any.any_l ()
| & _15: MutBorrow.t t_Sparse_i32 = Any.any_l ()
| & _16: () = Any.any_l ()
| & _17: MutBorrow.t t_Sparse_i32'0 = Any.any_l ()
| & _18: t_Option_ref_i32 = Any.any_l ()
| & _20: t_Option_ref_i32 = Any.any_l ()
| & _28: t_Option_ref_i32 = Any.any_l ()
| & _30: t_Option_ref_i32 = Any.any_l ()
| & _36: t_Option_ref_i32 = Any.any_l ()
| & _38: t_Option_ref_i32 = Any.any_l ()
| & _44: t_Option_ref_i32 = Any.any_l ()
| & _46: t_Option_ref_i32 = Any.any_l () ]) [ return (result: ()) -> (! return {result}) ]
end
module M_impl_Resolve_for_Sparse_T__resolve_coherence (* <Sparse<T, SIZE> as creusot_std::resolve::Resolve> *)
use creusot.int.UInt64
use creusot.slice.Slice64
use seq.Seq
use int.Int
type t_T
type t_Sparse_T = {
n: UInt64.t;
values: Slice64.array t_T;
idx: Slice64.array UInt64.t;
back: Slice64.array UInt64.t }
constant const_SIZE : UInt64.t
function index_array_usize_n [@inline:trivial] (self: Slice64.array UInt64.t) (ix: int) : UInt64.t =
Seq.get (Slice64.view self) ix
meta "rewrite_def" function index_array_usize_n
predicate invariant_Sparse_T (self: t_Sparse_T) =
UInt64.t'int self.n <= UInt64.t'int const_SIZE
/\ (forall i: int. 0 <= i /\ i < UInt64.t'int self.n
-> (let j = index_array_usize_n self.back i in 0 <= UInt64.t'int j
/\ UInt64.t'int j < UInt64.t'int const_SIZE /\ UInt64.t'int (index_array_usize_n self.idx (UInt64.t'int j)) = i))
predicate inv_T (_1: t_T)
predicate invariant_ref_T [@inline:trivial] (self: t_T) = inv_T self
meta "rewrite_def" predicate invariant_ref_T
predicate inv_ref_T [@inline:trivial] (_1: t_T) = invariant_ref_T _1
meta "rewrite_def" predicate inv_ref_T
predicate invariant_Seq_T [@inline:trivial] (self: Seq.seq t_T) =
forall i: int. 0 <= i /\ i < Seq.length self -> inv_ref_T (Seq.get self i)
meta "rewrite_def" predicate invariant_Seq_T
predicate inv_Seq_T [@inline:trivial] (_1: Seq.seq t_T) = invariant_Seq_T _1
meta "rewrite_def" predicate inv_Seq_T
predicate invariant_array_T_n (self: Slice64.array t_T) =
inv_Seq_T (Slice64.view self) /\ Seq.length (Slice64.view self) = UInt64.t'int const_SIZE
predicate inv_array_T_n [@inline:trivial] (_1: Slice64.array t_T) = invariant_array_T_n _1
meta "rewrite_def" predicate inv_array_T_n
predicate inv_Seq_usize [@inline:trivial] (_1: Seq.seq UInt64.t) = true
meta "rewrite_def" predicate inv_Seq_usize
predicate invariant_array_usize_n (self: Slice64.array UInt64.t) =
inv_Seq_usize (Slice64.view self) /\ Seq.length (Slice64.view self) = UInt64.t'int const_SIZE
predicate inv_array_usize_n [@inline:trivial] (_1: Slice64.array UInt64.t) = invariant_array_usize_n _1
meta "rewrite_def" predicate inv_array_usize_n
predicate inv_Sparse_T (_1: t_Sparse_T)
axiom inv_axiom [@rewrite]: forall x: t_Sparse_T [inv_Sparse_T x]. inv_Sparse_T x
= (invariant_Sparse_T x /\ inv_array_T_n x.values /\ inv_array_usize_n x.idx /\ inv_array_usize_n x.back)
predicate resolve_T (_1: t_T)
predicate resolve_array_T_n [@inline:trivial] (self: Slice64.array t_T) =
forall i: int. 0 <= i /\ i < UInt64.t'int const_SIZE -> resolve_T (Seq.get (Slice64.view self) i)
meta "rewrite_def" predicate resolve_array_T_n
predicate resolve_array_T_n'0 [@inline:trivial] (_1: Slice64.array t_T) = resolve_array_T_n _1
meta "rewrite_def" predicate resolve_array_T_n'0
predicate structural_resolve_Sparse_T (_1: t_Sparse_T) = resolve_array_T_n'0 _1.values
type t_Option_T = None | Some t_T
predicate resolve_Option_T (_1: t_Option_T)
axiom resolve_axiom [@rewrite]: forall x: t_Option_T [resolve_Option_T x]. resolve_Option_T x
= match x with
| None -> true
| Some x0 -> resolve_T x0
end
predicate is_elt_T (self: t_Sparse_T) (i: int) =
UInt64.t'int (index_array_usize_n self.idx i) < UInt64.t'int self.n
/\ UInt64.t'int (index_array_usize_n self.back (UInt64.t'int (index_array_usize_n self.idx i))) = i
function index_array_T_n [@inline:trivial] (self: Slice64.array t_T) (ix: int) : t_T = Seq.get (Slice64.view self) ix
meta "rewrite_def" function index_array_T_n
function view_Sparse_T (self: t_Sparse_T) : Seq.seq t_Option_T =
Seq.create (UInt64.t'int const_SIZE) (fun (i: int) -> if is_elt_T self i then
Some (index_array_T_n self.values i)
else
None
)
axiom view_Sparse_T_spec: forall self: t_Sparse_T [view_Sparse_T self]. Seq.length (view_Sparse_T self)
= UInt64.t'int const_SIZE
predicate resolve_Sparse_T (self: t_Sparse_T) =
forall i: int. 0 <= i /\ i < UInt64.t'int const_SIZE -> resolve_Option_T (Seq.get (view_Sparse_T self) i)
meta "compute_max_steps" 1000000
meta "select_lsinst" "all"
constant self : t_Sparse_T
function resolve_coherence_Sparse_T (self: t_Sparse_T) : ()
goal vc_resolve_coherence_Sparse_T: inv_Sparse_T self
-> structural_resolve_Sparse_T self -> ([@stop_split] [@expl:resolve_coherence ensures] resolve_Sparse_T self)
end
module M_impl_Resolve_for_Sparse_T__resolve_coherence__refines (* <Sparse<T, SIZE> as creusot_std::resolve::Resolve> *)
use creusot.int.UInt64
use creusot.slice.Slice64
use seq.Seq
use int.Int
type t_T
type t_Sparse_T = {
n: UInt64.t;
values: Slice64.array t_T;
idx: Slice64.array UInt64.t;
back: Slice64.array UInt64.t }
constant const_SIZE : UInt64.t
function index_array_usize_n [@inline:trivial] (self: Slice64.array UInt64.t) (ix: int) : UInt64.t =
Seq.get (Slice64.view self) ix
meta "rewrite_def" function index_array_usize_n
predicate invariant_Sparse_T (self: t_Sparse_T) =
UInt64.t'int self.n <= UInt64.t'int const_SIZE
/\ (forall i: int. 0 <= i /\ i < UInt64.t'int self.n
-> (let j = index_array_usize_n self.back i in 0 <= UInt64.t'int j
/\ UInt64.t'int j < UInt64.t'int const_SIZE /\ UInt64.t'int (index_array_usize_n self.idx (UInt64.t'int j)) = i))
predicate inv_T (_1: t_T)
predicate invariant_ref_T [@inline:trivial] (self: t_T) = inv_T self
meta "rewrite_def" predicate invariant_ref_T
predicate inv_ref_T [@inline:trivial] (_1: t_T) = invariant_ref_T _1
meta "rewrite_def" predicate inv_ref_T
predicate invariant_Seq_T [@inline:trivial] (self: Seq.seq t_T) =
forall i: int. 0 <= i /\ i < Seq.length self -> inv_ref_T (Seq.get self i)
meta "rewrite_def" predicate invariant_Seq_T
predicate inv_Seq_T [@inline:trivial] (_1: Seq.seq t_T) = invariant_Seq_T _1
meta "rewrite_def" predicate inv_Seq_T
predicate invariant_array_T_n (self: Slice64.array t_T) =
inv_Seq_T (Slice64.view self) /\ Seq.length (Slice64.view self) = UInt64.t'int const_SIZE
predicate inv_array_T_n [@inline:trivial] (_1: Slice64.array t_T) = invariant_array_T_n _1
meta "rewrite_def" predicate inv_array_T_n
predicate inv_Seq_usize [@inline:trivial] (_1: Seq.seq UInt64.t) = true
meta "rewrite_def" predicate inv_Seq_usize
predicate invariant_array_usize_n (self: Slice64.array UInt64.t) =
inv_Seq_usize (Slice64.view self) /\ Seq.length (Slice64.view self) = UInt64.t'int const_SIZE
predicate inv_array_usize_n [@inline:trivial] (_1: Slice64.array UInt64.t) = invariant_array_usize_n _1
meta "rewrite_def" predicate inv_array_usize_n
predicate inv_Sparse_T (_1: t_Sparse_T)
axiom inv_axiom [@rewrite]: forall x: t_Sparse_T [inv_Sparse_T x]. inv_Sparse_T x
= (invariant_Sparse_T x /\ inv_array_T_n x.values /\ inv_array_usize_n x.idx /\ inv_array_usize_n x.back)
predicate resolve_T (_1: t_T)
predicate resolve_array_T_n [@inline:trivial] (self: Slice64.array t_T) =
forall i: int. 0 <= i /\ i < UInt64.t'int const_SIZE -> resolve_T (Seq.get (Slice64.view self) i)
meta "rewrite_def" predicate resolve_array_T_n
predicate resolve_array_T_n'0 [@inline:trivial] (_1: Slice64.array t_T) = resolve_array_T_n _1
meta "rewrite_def" predicate resolve_array_T_n'0
predicate structural_resolve_Sparse_T (_1: t_Sparse_T) = resolve_array_T_n'0 _1.values
type t_Option_T = None | Some t_T
predicate resolve_Option_T (_1: t_Option_T)
axiom resolve_axiom [@rewrite]: forall x: t_Option_T [resolve_Option_T x]. resolve_Option_T x
= match x with
| None -> true
| Some x0 -> resolve_T x0
end
predicate is_elt_T (self: t_Sparse_T) (i: int) =
UInt64.t'int (index_array_usize_n self.idx i) < UInt64.t'int self.n
/\ UInt64.t'int (index_array_usize_n self.back (UInt64.t'int (index_array_usize_n self.idx i))) = i
function index_array_T_n [@inline:trivial] (self: Slice64.array t_T) (ix: int) : t_T = Seq.get (Slice64.view self) ix
meta "rewrite_def" function index_array_T_n
function view_Sparse_T (self: t_Sparse_T) : Seq.seq t_Option_T =
Seq.create (UInt64.t'int const_SIZE) (fun (i: int) -> if is_elt_T self i then
Some (index_array_T_n self.values i)
else
None
)
axiom view_Sparse_T_spec: forall self: t_Sparse_T [view_Sparse_T self]. Seq.length (view_Sparse_T self)
= UInt64.t'int const_SIZE
predicate resolve_Sparse_T (self: t_Sparse_T) =
forall i: int. 0 <= i /\ i < UInt64.t'int const_SIZE -> resolve_Option_T (Seq.get (view_Sparse_T self) i)
meta "compute_max_steps" 1000000
meta "select_lsinst" "all"
goal refines: forall self: t_Sparse_T. inv_Sparse_T self
-> structural_resolve_Sparse_T self
-> inv_Sparse_T self
/\ structural_resolve_Sparse_T self /\ (forall result: (). resolve_Sparse_T self -> resolve_Sparse_T self)
end
module M_impl_Sparse_T__bounded_fset_len (* Sparse<T, SIZE> *)
use set.Fset
use int.Int
predicate contains_Int [@inline:trivial] (self: Fset.fset int) (e: int) = Fset.mem e self
meta "rewrite_def" predicate contains_Int
predicate ge_log_Int [@inline:trivial] (self: int) (other: int) = other <= self
meta "rewrite_def" predicate ge_log_Int
predicate gt_log_Int [@inline:trivial] (self: int) (other: int) = other < self
meta "rewrite_def" predicate gt_log_Int
function remove_Int [@inline:trivial] (self: Fset.fset int) (e: int) : Fset.fset int = Fset.remove e self
meta "rewrite_def" function remove_Int
predicate well_founded_relation_Int [@inline:trivial] (self: int) (other: int) =
ge_log_Int self 0 /\ gt_log_Int self other
meta "rewrite_def" predicate well_founded_relation_Int
meta "compute_max_steps" 1000000
meta "select_lsinst" "all"
constant s : Fset.fset int
constant bnd : int
function bounded_fset_len_T (s: Fset.fset int) (bnd: int) : ()
goal vc_bounded_fset_len_T: (forall x: int. contains_Int s x -> 0 <= x /\ x < bnd)
-> ge_log_Int bnd 0
-> (if gt_log_Int bnd 0 then
(([@stop_split] [@expl:bounded_fset_len requires] ([@stop_split] [@expl:bounded_fset_len requires #0] forall x: int. contains_Int (remove_Int s (bnd
- 1)) x -> 0 <= x /\ x < bnd - 1)
/\ ([@stop_split] [@expl:bounded_fset_len requires #1] ge_log_Int (bnd - 1) 0))
/\ ([@expl:variant decreases] well_founded_relation_Int bnd (bnd - 1)))
/\ (([@stop_split] [@expl:bounded_fset_len ensures] Fset.cardinal (remove_Int s (bnd - 1)) <= bnd - 1)
-> ([@stop_split] [@expl:bounded_fset_len ensures] Fset.cardinal s <= bnd))
else
[@stop_split] [@expl:bounded_fset_len ensures] Fset.cardinal s <= bnd
)
end
module M_impl_Sparse_T__get (* Sparse<T, SIZE> *)
use creusot.int.UInt64
use creusot.slice.Slice64
use creusot.prelude.Any
use seq.Seq
use int.Int
constant const_SIZE : UInt64.t
type t_T
type t_Sparse_T = {
n: UInt64.t;
values: Slice64.array t_T;
idx: Slice64.array UInt64.t;
back: Slice64.array UInt64.t }
type t_Option_ref_T = None | Some t_T
function index_array_usize_n [@inline:trivial] (self: Slice64.array UInt64.t) (ix: int) : UInt64.t =
Seq.get (Slice64.view self) ix
meta "rewrite_def" function index_array_usize_n
predicate invariant_Sparse_T (self: t_Sparse_T) =
UInt64.t'int self.n <= UInt64.t'int const_SIZE
/\ (forall i: int. 0 <= i /\ i < UInt64.t'int self.n
-> (let j = index_array_usize_n self.back i in 0 <= UInt64.t'int j
/\ UInt64.t'int j < UInt64.t'int const_SIZE /\ UInt64.t'int (index_array_usize_n self.idx (UInt64.t'int j)) = i))
predicate inv_T (_1: t_T)
predicate invariant_ref_T [@inline:trivial] (self: t_T) = inv_T self
meta "rewrite_def" predicate invariant_ref_T
predicate inv_ref_T [@inline:trivial] (_1: t_T) = invariant_ref_T _1
meta "rewrite_def" predicate inv_ref_T
predicate invariant_Seq_T [@inline:trivial] (self: Seq.seq t_T) =
forall i: int. 0 <= i /\ i < Seq.length self -> inv_ref_T (Seq.get self i)
meta "rewrite_def" predicate invariant_Seq_T
predicate inv_Seq_T [@inline:trivial] (_1: Seq.seq t_T) = invariant_Seq_T _1
meta "rewrite_def" predicate inv_Seq_T
predicate invariant_array_T_n (self: Slice64.array t_T) =
inv_Seq_T (Slice64.view self) /\ Seq.length (Slice64.view self) = UInt64.t'int const_SIZE
predicate inv_array_T_n [@inline:trivial] (_1: Slice64.array t_T) = invariant_array_T_n _1
meta "rewrite_def" predicate inv_array_T_n
predicate inv_Seq_usize [@inline:trivial] (_1: Seq.seq UInt64.t) = true
meta "rewrite_def" predicate inv_Seq_usize
predicate invariant_array_usize_n (self: Slice64.array UInt64.t) =
inv_Seq_usize (Slice64.view self) /\ Seq.length (Slice64.view self) = UInt64.t'int const_SIZE
predicate inv_array_usize_n [@inline:trivial] (_1: Slice64.array UInt64.t) = invariant_array_usize_n _1
meta "rewrite_def" predicate inv_array_usize_n
predicate inv_Sparse_T (_1: t_Sparse_T)
axiom inv_axiom [@rewrite]: forall x: t_Sparse_T [inv_Sparse_T x]. inv_Sparse_T x
= (invariant_Sparse_T x /\ inv_array_T_n x.values /\ inv_array_usize_n x.idx /\ inv_array_usize_n x.back)
predicate invariant_ref_Sparse_T [@inline:trivial] (self: t_Sparse_T) = inv_Sparse_T self
meta "rewrite_def" predicate invariant_ref_Sparse_T
predicate inv_ref_Sparse_T [@inline:trivial] (_1: t_Sparse_T) = invariant_ref_Sparse_T _1
meta "rewrite_def" predicate inv_ref_Sparse_T
predicate inv_Option_ref_T (_1: t_Option_ref_T)
axiom inv_axiom'0 [@rewrite]: forall x: t_Option_ref_T [inv_Option_ref_T x]. inv_Option_ref_T x
= match x with
| None -> true
| Some f0 -> inv_ref_T f0
end
type t_Option_T = None'0 | Some'0 t_T
predicate is_elt_T (self: t_Sparse_T) (i: int) =
UInt64.t'int (index_array_usize_n self.idx i) < UInt64.t'int self.n
/\ UInt64.t'int (index_array_usize_n self.back (UInt64.t'int (index_array_usize_n self.idx i))) = i
function index_array_T_n [@inline:trivial] (self: Slice64.array t_T) (ix: int) : t_T = Seq.get (Slice64.view self) ix
meta "rewrite_def" function index_array_T_n
function view_Sparse_T (self: t_Sparse_T) : Seq.seq t_Option_T =
Seq.create (UInt64.t'int const_SIZE) (fun (i: int) -> if is_elt_T self i then
Some'0 (index_array_T_n self.values i)
else
None'0
)
axiom view_Sparse_T_spec: forall self: t_Sparse_T [view_Sparse_T self]. Seq.length (view_Sparse_T self)
= UInt64.t'int const_SIZE
meta "compute_max_steps" 1000000
meta "select_lsinst" "all"
let get_T (self: t_Sparse_T) (i: UInt64.t) (return (x: t_Option_ref_T)) =
{[@stop_split] [@expl:get_T requires] ([@stop_split] [@expl:get 'self' type invariant] inv_ref_Sparse_T self)
/\ ([@stop_split] [@expl:get requires] UInt64.t'int i < UInt64.t'int const_SIZE)}
(! bb0
[ bb0 = s0
[ s0 = [ &_12 <- i ] s1
| s1 = [ &_13 <- UInt64.lt _12 const_SIZE ] s2
| s2 = {[@expl:index in bounds] _13} s3
| s3 = Slice64.get <UInt64.t> {self.idx} {_12} (fun (r: UInt64.t) -> [ &index <- r ] s4)
| s4 = [ &_14 <- UInt64.lt index self.n ] s5
| s5 = any [ br0 -> {_14 = false} (! bb8) | br1 -> {_14} (! bb2) ] ]
| bb2 = s0
[ s0 = [ &_19 <- index ] s1
| s1 = [ &_20 <- UInt64.lt _19 const_SIZE ] s2
| s2 = {[@expl:index in bounds] _20} s3
| s3 = Slice64.get <UInt64.t> {self.back} {_19} (fun (r: UInt64.t) -> [ &_18 <- r ] s4)
| s4 = [ &_17 <- _18 = i ] s5
| s5 = any [ br0 -> {_17 = false} (! bb8) | br1 -> {_17} (! bb4) ] ]
| bb4 = s0
[ s0 = [ &_24 <- i ] s1
| s1 = [ &_25 <- UInt64.lt _24 const_SIZE ] s2
| s2 = {[@expl:index in bounds] _25} s3
| s3 = Slice64.get <t_T> {self.values} {_24} (fun (r: t_T) -> [ &_23 <- r ] s4)
| s4 = [ &_ret <- Some _23 ] s5
| s5 = return {_ret} ]
| bb8 = s0 [ s0 = [ &_ret <- None ] s1 | s1 = return {_ret} ] ]
[ & _ret: t_Option_ref_T = Any.any_l ()
| & self: t_Sparse_T = self
| & i: UInt64.t = i
| & index: UInt64.t = Any.any_l ()
| & _12: UInt64.t = Any.any_l ()
| & _13: bool = Any.any_l ()
| & _14: bool = Any.any_l ()
| & _17: bool = Any.any_l ()
| & _18: UInt64.t = Any.any_l ()
| & _19: UInt64.t = Any.any_l ()
| & _20: bool = Any.any_l ()
| & _23: t_T = Any.any_l ()
| & _24: UInt64.t = Any.any_l ()
| & _25: bool = Any.any_l () ])
[ return (result: t_Option_ref_T) ->
{[@stop_split] [@expl:get_T ensures] ([@stop_split] [@expl:get result type invariant] inv_Option_ref_T result)
/\ ([@stop_split] [@expl:get ensures #0] match result with
| None -> Seq.get (view_Sparse_T self) (UInt64.t'int i) = None'0
| Some x -> Seq.get (view_Sparse_T self) (UInt64.t'int i) = Some'0 x
end)
/\ ([@stop_split] [@expl:get ensures #1] match Seq.get (view_Sparse_T self) (UInt64.t'int i) with
| None'0 -> result = None
| Some'0 _ -> true
end)}
(! return {result}) ]
end
module M_impl_Sparse_T__lemma_permutation (* Sparse<T, SIZE> *)
use creusot.int.UInt64
use creusot.slice.Slice64
use seq.Seq
use set.Fset
use int.Int
type t_T
type t_Sparse_T = {
n: UInt64.t;
values: Slice64.array t_T;
idx: Slice64.array UInt64.t;
back: Slice64.array UInt64.t }
constant const_SIZE : UInt64.t
function index_array_usize_n [@inline:trivial] (self: Slice64.array UInt64.t) (ix: int) : UInt64.t =
Seq.get (Slice64.view self) ix
meta "rewrite_def" function index_array_usize_n
predicate invariant_Sparse_T (self: t_Sparse_T) =
UInt64.t'int self.n <= UInt64.t'int const_SIZE
/\ (forall i: int. 0 <= i /\ i < UInt64.t'int self.n
-> (let j = index_array_usize_n self.back i in 0 <= UInt64.t'int j
/\ UInt64.t'int j < UInt64.t'int const_SIZE /\ UInt64.t'int (index_array_usize_n self.idx (UInt64.t'int j)) = i))
predicate inv_T (_1: t_T)
predicate invariant_ref_T [@inline:trivial] (self: t_T) = inv_T self
meta "rewrite_def" predicate invariant_ref_T
predicate inv_ref_T [@inline:trivial] (_1: t_T) = invariant_ref_T _1
meta "rewrite_def" predicate inv_ref_T
predicate invariant_Seq_T [@inline:trivial] (self: Seq.seq t_T) =
forall i: int. 0 <= i /\ i < Seq.length self -> inv_ref_T (Seq.get self i)
meta "rewrite_def" predicate invariant_Seq_T
predicate inv_Seq_T [@inline:trivial] (_1: Seq.seq t_T) = invariant_Seq_T _1
meta "rewrite_def" predicate inv_Seq_T
predicate invariant_array_T_n (self: Slice64.array t_T) =
inv_Seq_T (Slice64.view self) /\ Seq.length (Slice64.view self) = UInt64.t'int const_SIZE
predicate inv_array_T_n [@inline:trivial] (_1: Slice64.array t_T) = invariant_array_T_n _1
meta "rewrite_def" predicate inv_array_T_n
predicate inv_Seq_usize [@inline:trivial] (_1: Seq.seq UInt64.t) = true
meta "rewrite_def" predicate inv_Seq_usize
predicate invariant_array_usize_n (self: Slice64.array UInt64.t) =
inv_Seq_usize (Slice64.view self) /\ Seq.length (Slice64.view self) = UInt64.t'int const_SIZE
predicate inv_array_usize_n [@inline:trivial] (_1: Slice64.array UInt64.t) = invariant_array_usize_n _1
meta "rewrite_def" predicate inv_array_usize_n
predicate inv_Sparse_T (_1: t_Sparse_T)
axiom inv_axiom [@rewrite]: forall x: t_Sparse_T [inv_Sparse_T x]. inv_Sparse_T x
= (invariant_Sparse_T x /\ inv_array_T_n x.values /\ inv_array_usize_n x.idx /\ inv_array_usize_n x.back)
predicate is_elt_T (self: t_Sparse_T) (i: int) =
UInt64.t'int (index_array_usize_n self.idx i) < UInt64.t'int self.n
/\ UInt64.t'int (index_array_usize_n self.back (UInt64.t'int (index_array_usize_n self.idx i))) = i
predicate contains_Int [@inline:trivial] (self: Fset.fset int) (e: int) = Fset.mem e self
meta "rewrite_def" predicate contains_Int
predicate ge_log_Int [@inline:trivial] (self: int) (other: int) = other <= self
meta "rewrite_def" predicate ge_log_Int
predicate gt_log_Int [@inline:trivial] (self: int) (other: int) = other < self
meta "rewrite_def" predicate gt_log_Int
function remove_Int [@inline:trivial] (self: Fset.fset int) (e: int) : Fset.fset int = Fset.remove e self
meta "rewrite_def" function remove_Int
function bounded_fset_len_T (s: Fset.fset int) (bnd: int) : ()
axiom bounded_fset_len_T_def:
forall s: Fset.fset int, bnd: int [bounded_fset_len_T s bnd]. (forall x: int. contains_Int s x -> 0 <= x /\ x < bnd)
-> ge_log_Int bnd 0