-
Notifications
You must be signed in to change notification settings - Fork 72
Expand file tree
/
Copy pathsparse_array.coma
More file actions
1524 lines (1115 loc) · 64.7 KB
/
sparse_array.coma
File metadata and controls
1524 lines (1115 loc) · 64.7 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_impl_View_for_Sparse_T__view (* <Sparse<T, SIZE> as creusot_std::model::View> *)
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 }
type t_Option_T = None | Some t_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 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
meta "compute_max_steps" 1000000
meta "select_lsinst" "all"
constant self : t_Sparse_T
function view_Sparse_T (self: t_Sparse_T) : Seq.seq t_Option_T
goal vc_view_Sparse_T:
[@stop_split] [@expl:view ensures] Seq.length (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
))
= UInt64.t'int const_SIZE
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 (_1: Slice64.array t_T)
axiom resolve_axiom: forall x: Slice64.array t_T [resolve_array_T_n'0 x]. resolve_array_T_n'0 x -> resolve_array_T_n x
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'0 [@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. 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_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. Seq.length (view_Sparse_T self) = UInt64.t'int const_SIZE
meta "compute_max_steps" 1000000
meta "select_lsinst" "all"
let rec 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
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. (forall x: int. contains_Int s x
-> 0 <= x /\ x < bnd)
-> bnd >= 0
-> bounded_fset_len_T s bnd = (if bnd > 0 then bounded_fset_len_T (remove_Int s (bnd - 1)) (bnd - 1) else ())
axiom bounded_fset_len_T_spec: forall s: Fset.fset int, bnd: int. (forall x: int. contains_Int s x
-> 0 <= x /\ x < bnd) -> bnd >= 0 -> Fset.cardinal s <= bnd
function insert_Int [@inline:trivial] (self: Fset.fset int) (e: int) : Fset.fset int = Fset.add e self
meta "rewrite_def" function insert_Int
function lemma_permutation_aux_T (self: t_Sparse_T) (seen: Fset.fset int) (i: int) (cur: int) : int
axiom lemma_permutation_aux_T_def: forall self: t_Sparse_T, seen: Fset.fset int, i: int, cur: int. inv_Sparse_T self
-> self.n = const_SIZE
-> 0 <= cur /\ cur < UInt64.t'int const_SIZE
-> (forall k: int. contains_Int seen k
-> 0 <= k
/\ k < UInt64.t'int const_SIZE
/\ (k = i \/ contains_Int seen (UInt64.t'int (index_array_usize_n self.idx k))))
-> i = cur \/ contains_Int seen i /\ contains_Int seen (UInt64.t'int (index_array_usize_n self.idx cur))
-> not contains_Int seen cur
-> lemma_permutation_aux_T self seen i cur
= (if UInt64.t'int (index_array_usize_n self.back cur) = i then
cur
else
let _ = bounded_fset_len_T seen (UInt64.t'int const_SIZE) in lemma_permutation_aux_T self (insert_Int seen cur) i (UInt64.t'int (index_array_usize_n self.back cur))
)
axiom lemma_permutation_aux_T_spec: forall self: t_Sparse_T, seen: Fset.fset int, i: int, cur: int. inv_Sparse_T self
-> self.n = const_SIZE
-> 0 <= cur /\ cur < UInt64.t'int const_SIZE
-> (forall k: int. contains_Int seen k
-> 0 <= k
/\ k < UInt64.t'int const_SIZE
/\ (k = i \/ contains_Int seen (UInt64.t'int (index_array_usize_n self.idx k))))
-> i = cur \/ contains_Int seen i /\ contains_Int seen (UInt64.t'int (index_array_usize_n self.idx cur))
-> not contains_Int seen cur
-> 0 <= lemma_permutation_aux_T self seen i cur
/\ lemma_permutation_aux_T self seen i cur < UInt64.t'int const_SIZE
axiom lemma_permutation_aux_T_spec'0:
forall self: t_Sparse_T, seen: Fset.fset int, i: int, cur: int. inv_Sparse_T self
-> self.n = const_SIZE
-> 0 <= cur /\ cur < UInt64.t'int const_SIZE
-> (forall k: int. contains_Int seen k
-> 0 <= k
/\ k < UInt64.t'int const_SIZE
/\ (k = i \/ contains_Int seen (UInt64.t'int (index_array_usize_n self.idx k))))
-> i = cur \/ contains_Int seen i /\ contains_Int seen (UInt64.t'int (index_array_usize_n self.idx cur))
-> not contains_Int seen cur
-> UInt64.t'int (index_array_usize_n self.back (lemma_permutation_aux_T self seen i cur)) = i
meta "compute_max_steps" 1000000
meta "select_lsinst" "all"
constant self : t_Sparse_T
constant i : int
function lemma_permutation_T (self: t_Sparse_T) (i: int) : ()
goal vc_lemma_permutation_T: inv_Sparse_T self
-> self.n = const_SIZE
-> 0 <= i /\ i < UInt64.t'int const_SIZE
-> ([@stop_split] [@expl:lemma_permutation_aux requires] ([@stop_split] [@expl:lemma_permutation_aux requires #0] inv_Sparse_T self)
/\ ([@stop_split] [@expl:lemma_permutation_aux requires #1] self.n = const_SIZE)
/\ ([@stop_split] [@expl:lemma_permutation_aux requires #2] 0 <= i /\ i < UInt64.t'int const_SIZE)
/\ ([@stop_split] [@expl:lemma_permutation_aux requires #3] forall k: int. contains_Int (Fset.empty: Fset.fset int) k
-> 0 <= k
/\ k < UInt64.t'int const_SIZE
/\ (k = i \/ contains_Int (Fset.empty: Fset.fset int) (UInt64.t'int (index_array_usize_n self.idx k))))
/\ ([@stop_split] [@expl:lemma_permutation_aux requires #4] i = i
\/ contains_Int (Fset.empty: Fset.fset int) i
/\ contains_Int (Fset.empty: Fset.fset int) (UInt64.t'int (index_array_usize_n self.idx i)))
/\ ([@stop_split] [@expl:lemma_permutation_aux requires #5] not contains_Int (Fset.empty: Fset.fset int) i))
/\ (([@stop_split] [@expl:lemma_permutation_aux ensures] ([@stop_split] [@expl:lemma_permutation_aux ensures #0] 0
<= lemma_permutation_aux_T self (Fset.empty: Fset.fset int) i i
/\ lemma_permutation_aux_T self (Fset.empty: Fset.fset int) i i < UInt64.t'int const_SIZE)
/\ ([@stop_split] [@expl:lemma_permutation_aux ensures #1] UInt64.t'int (index_array_usize_n self.back (lemma_permutation_aux_T self (Fset.empty: Fset.fset int) i i))
= i))
-> (let _ = lemma_permutation_aux_T self (Fset.empty: Fset.fset int) i i in [@stop_split] [@expl:lemma_permutation ensures] is_elt_T self i))
end
module M_impl_Sparse_T__lemma_permutation_aux (* Sparse<T, SIZE> *)
use creusot.int.UInt64
use creusot.slice.Slice64
use set.Fset
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 contains_Int [@inline:trivial] (self: Fset.fset int) (e: int) = Fset.mem e self
meta "rewrite_def" predicate contains_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. (forall x: int. contains_Int s x
-> 0 <= x /\ x < bnd)
-> bnd >= 0
-> bounded_fset_len_T s bnd = (if bnd > 0 then bounded_fset_len_T (remove_Int s (bnd - 1)) (bnd - 1) else ())
axiom bounded_fset_len_T_spec: forall s: Fset.fset int, bnd: int. (forall x: int. contains_Int s x
-> 0 <= x /\ x < bnd) -> bnd >= 0 -> Fset.cardinal s <= bnd
function insert_Int [@inline:trivial] (self: Fset.fset int) (e: int) : Fset.fset int = Fset.add e self
meta "rewrite_def" function insert_Int
predicate well_founded_relation_Int [@inline:trivial] (self: int) (other: int) = self >= 0 /\ self > other
meta "rewrite_def" predicate well_founded_relation_Int
meta "compute_max_steps" 1000000
meta "select_lsinst" "all"
constant self : t_Sparse_T
constant seen : Fset.fset int
constant i : int
constant cur : int
function lemma_permutation_aux_T (self: t_Sparse_T) (seen: Fset.fset int) (i: int) (cur: int) : int
goal vc_lemma_permutation_aux_T: inv_Sparse_T self
-> self.n = const_SIZE
-> 0 <= cur /\ cur < UInt64.t'int const_SIZE
-> (forall k: int. contains_Int seen k
-> 0 <= k
/\ k < UInt64.t'int const_SIZE /\ (k = i \/ contains_Int seen (UInt64.t'int (index_array_usize_n self.idx k))))
-> i = cur \/ contains_Int seen i /\ contains_Int seen (UInt64.t'int (index_array_usize_n self.idx cur))
-> not contains_Int seen cur
-> (if UInt64.t'int (index_array_usize_n self.back cur) = i then
let result = cur in [@stop_split] [@expl:lemma_permutation_aux_T ensures] ([@stop_split] [@expl:lemma_permutation_aux ensures #0] 0
<= result
/\ result < UInt64.t'int const_SIZE)
/\ ([@stop_split] [@expl:lemma_permutation_aux ensures #1] UInt64.t'int (index_array_usize_n self.back result)
= i)
else
([@stop_split] [@expl:bounded_fset_len requires] ([@stop_split] [@expl:bounded_fset_len requires #0] forall x: int. contains_Int seen x
-> 0 <= x /\ x < UInt64.t'int const_SIZE)
/\ ([@stop_split] [@expl:bounded_fset_len requires #1] UInt64.t'int const_SIZE >= 0))
/\ (([@stop_split] [@expl:bounded_fset_len ensures] Fset.cardinal seen <= UInt64.t'int const_SIZE)
-> (let _ = bounded_fset_len_T seen (UInt64.t'int const_SIZE) in (([@stop_split] [@expl:lemma_permutation_aux requires] ([@stop_split] [@expl:lemma_permutation_aux requires #0] inv_Sparse_T self)
/\ ([@stop_split] [@expl:lemma_permutation_aux requires #1] self.n = const_SIZE)
/\ ([@stop_split] [@expl:lemma_permutation_aux requires #2] 0
<= UInt64.t'int (index_array_usize_n self.back cur)
/\ UInt64.t'int (index_array_usize_n self.back cur) < UInt64.t'int const_SIZE)
/\ ([@stop_split] [@expl:lemma_permutation_aux requires #3] forall k: int. contains_Int (insert_Int seen cur) k
-> 0 <= k
/\ k < UInt64.t'int const_SIZE
/\ (k = i \/ contains_Int (insert_Int seen cur) (UInt64.t'int (index_array_usize_n self.idx k))))
/\ ([@stop_split] [@expl:lemma_permutation_aux requires #4] i
= UInt64.t'int (index_array_usize_n self.back cur)
\/ contains_Int (insert_Int seen cur) i
/\ contains_Int (insert_Int seen cur) (UInt64.t'int (index_array_usize_n self.idx (UInt64.t'int (index_array_usize_n self.back cur)))))
/\ ([@stop_split] [@expl:lemma_permutation_aux requires #5] not contains_Int (insert_Int seen cur) (UInt64.t'int (index_array_usize_n self.back cur))))
/\ ([@expl:variant decreases] well_founded_relation_Int (UInt64.t'int const_SIZE
- Fset.cardinal seen) (UInt64.t'int const_SIZE - Fset.cardinal (insert_Int seen cur))))
/\ (([@stop_split] [@expl:lemma_permutation_aux ensures] ([@stop_split] [@expl:lemma_permutation_aux ensures #0] 0
<= lemma_permutation_aux_T self (insert_Int seen cur) i (UInt64.t'int (index_array_usize_n self.back cur))
/\ lemma_permutation_aux_T self (insert_Int seen cur) i (UInt64.t'int (index_array_usize_n self.back cur))
< UInt64.t'int const_SIZE)
/\ ([@stop_split] [@expl:lemma_permutation_aux ensures #1] UInt64.t'int (index_array_usize_n self.back (lemma_permutation_aux_T self (insert_Int seen cur) i (UInt64.t'int (index_array_usize_n self.back cur))))
= i))
-> (let result = lemma_permutation_aux_T self (insert_Int seen cur) i (UInt64.t'int (index_array_usize_n self.back cur)) in [@stop_split] [@expl:lemma_permutation_aux_T ensures] ([@stop_split] [@expl:lemma_permutation_aux ensures #0] 0
<= result
/\ result < UInt64.t'int const_SIZE)
/\ ([@stop_split] [@expl:lemma_permutation_aux ensures #1] UInt64.t'int (index_array_usize_n self.back result)
= i)))))
)
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
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) = self >= 0 /\ 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)
-> bnd >= 0
-> (if 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] 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__set (* Sparse<T, SIZE> *)
use creusot.int.UInt64
use creusot.slice.Slice64
use seq.Seq
use creusot.prelude.MutBorrow
use set.Fset
use creusot.prelude.Any
use int.Int
constant const_SIZE : UInt64.t
type t_T
predicate inv_T (_1: t_T)
function index_array_T_n [@inline:trivial] (self: Slice64.array t_T) (ix: UInt64.t) : t_T =
Seq.get (Slice64.view self) (UInt64.t'int ix)
meta "rewrite_def" function index_array_T_n
type t_Sparse_T = {
n: UInt64.t;
values: Slice64.array t_T;
idx: Slice64.array UInt64.t;
back: Slice64.array UInt64.t }
predicate resolve_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)
predicate invariant_refmut_Sparse_T [@inline:trivial] (self: MutBorrow.t t_Sparse_T) =
inv_Sparse_T self.current /\ inv_Sparse_T self.final
meta "rewrite_def" predicate invariant_refmut_Sparse_T
predicate inv_refmut_Sparse_T [@inline:trivial] (_1: MutBorrow.t t_Sparse_T) = invariant_refmut_Sparse_T _1
meta "rewrite_def" predicate inv_refmut_Sparse_T
predicate resolve_refmut_Sparse_T [@inline:trivial] (_1: MutBorrow.t t_Sparse_T) = _1.final = _1.current
meta "rewrite_def" predicate resolve_refmut_Sparse_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
predicate contains_Int [@inline:trivial] (self: Fset.fset int) (e: int) = Fset.mem e self
meta "rewrite_def" predicate contains_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. (forall x: int. contains_Int s x
-> 0 <= x /\ x < bnd)
-> bnd >= 0
-> bounded_fset_len_T s bnd = (if bnd > 0 then bounded_fset_len_T (remove_Int s (bnd - 1)) (bnd - 1) else ())
axiom bounded_fset_len_T_spec: forall s: Fset.fset int, bnd: int. (forall x: int. contains_Int s x
-> 0 <= x /\ x < bnd) -> bnd >= 0 -> Fset.cardinal s <= bnd
function insert_Int [@inline:trivial] (self: Fset.fset int) (e: int) : Fset.fset int = Fset.add e self
meta "rewrite_def" function insert_Int
function lemma_permutation_aux_T (self: t_Sparse_T) (seen: Fset.fset int) (i: int) (cur: int) : int
axiom lemma_permutation_aux_T_def: forall self: t_Sparse_T, seen: Fset.fset int, i: int, cur: int. inv_Sparse_T self
-> self.n = const_SIZE
-> 0 <= cur /\ cur < UInt64.t'int const_SIZE
-> (forall k: int. contains_Int seen k
-> 0 <= k
/\ k < UInt64.t'int const_SIZE
/\ (k = i \/ contains_Int seen (UInt64.t'int (index_array_usize_n self.idx k))))
-> i = cur \/ contains_Int seen i /\ contains_Int seen (UInt64.t'int (index_array_usize_n self.idx cur))
-> not contains_Int seen cur
-> lemma_permutation_aux_T self seen i cur
= (if UInt64.t'int (index_array_usize_n self.back cur) = i then
cur
else
let _ = bounded_fset_len_T seen (UInt64.t'int const_SIZE) in lemma_permutation_aux_T self (insert_Int seen cur) i (UInt64.t'int (index_array_usize_n self.back cur))
)
axiom lemma_permutation_aux_T_spec: forall self: t_Sparse_T, seen: Fset.fset int, i: int, cur: int. inv_Sparse_T self
-> self.n = const_SIZE
-> 0 <= cur /\ cur < UInt64.t'int const_SIZE
-> (forall k: int. contains_Int seen k
-> 0 <= k
/\ k < UInt64.t'int const_SIZE
/\ (k = i \/ contains_Int seen (UInt64.t'int (index_array_usize_n self.idx k))))
-> i = cur \/ contains_Int seen i /\ contains_Int seen (UInt64.t'int (index_array_usize_n self.idx cur))
-> not contains_Int seen cur
-> 0 <= lemma_permutation_aux_T self seen i cur
/\ lemma_permutation_aux_T self seen i cur < UInt64.t'int const_SIZE
axiom lemma_permutation_aux_T_spec'0:
forall self: t_Sparse_T, seen: Fset.fset int, i: int, cur: int. inv_Sparse_T self
-> self.n = const_SIZE
-> 0 <= cur /\ cur < UInt64.t'int const_SIZE
-> (forall k: int. contains_Int seen k
-> 0 <= k
/\ k < UInt64.t'int const_SIZE
/\ (k = i \/ contains_Int seen (UInt64.t'int (index_array_usize_n self.idx k))))
-> i = cur \/ contains_Int seen i /\ contains_Int seen (UInt64.t'int (index_array_usize_n self.idx cur))
-> not contains_Int seen cur
-> UInt64.t'int (index_array_usize_n self.back (lemma_permutation_aux_T self seen i cur)) = i
function lemma_permutation_T (self: t_Sparse_T) (i: int) : () =
let _ = lemma_permutation_aux_T self (Fset.empty: Fset.fset int) i i in ()
axiom lemma_permutation_T_spec: forall self: t_Sparse_T, i: int. inv_Sparse_T self
-> self.n = const_SIZE -> 0 <= i /\ i < UInt64.t'int const_SIZE -> is_elt_T self i
type t_Option_T = None | Some t_T
function index_array_T_n'0 [@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'0
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'0 self.values i)
else
None
)
axiom view_Sparse_T_spec: forall self: t_Sparse_T. Seq.length (view_Sparse_T self) = UInt64.t'int const_SIZE
meta "compute_max_steps" 1000000
meta "select_lsinst" "all"
let rec set_T (self: MutBorrow.t t_Sparse_T) (i: UInt64.t) (v: t_T) (return (x: ())) =
{[@stop_split] [@expl:set_T requires] ([@stop_split] [@expl:set 'self' type invariant] inv_refmut_Sparse_T self)
/\ ([@stop_split] [@expl:set 'v' type invariant] inv_T v)
/\ ([@stop_split] [@expl:set requires] UInt64.t'int i < UInt64.t'int const_SIZE)}
(! bb0
[ bb0 = s0
[ s0 = [ &_14 <- i ] s1
| s1 = [ &_15 <- UInt64.lt _14 const_SIZE ] s2
| s2 = {[@expl:index in bounds] _15} s3
| s3 = s4 [ _ck -> (! {[@expl:type invariant] inv_T (index_array_T_n self.current.values _14)} any) ]
| s4 = -{resolve_T (index_array_T_n self.current.values _14)}- s5
| s5 = Slice64.set <t_T> {self.current.values} {_14} {v}
(fun (r: Slice64.array t_T) -> [ &self <- { self with current = { self.current with values = r } } ] s6)
| s6 = [ &_17 <- i ] s7
| s7 = [ &_18 <- UInt64.lt _17 const_SIZE ] s8
| s8 = {[@expl:index in bounds] _18} s9
| s9 = Slice64.get <UInt64.t> {self.current.idx} {_17} (fun (r: UInt64.t) -> [ &index <- r ] s10)
| s10 = [ &_19 <- UInt64.lt index self.current.n ] s11
| s11 = any [ br0 -> {_19 = false} (! bb11) | br1 -> {_19} (! bb6) ] ]
| bb6 = s0
[ s0 = [ &_24 <- index ] s1
| s1 = [ &_25 <- UInt64.lt _24 const_SIZE ] s2
| s2 = {[@expl:index in bounds] _25} s3
| s3 = Slice64.get <UInt64.t> {self.current.back} {_24} (fun (r: UInt64.t) -> [ &_23 <- r ] s4)
| s4 = [ &_22 <- _23 = i ] s5
| s5 = any [ br0 -> {_22 = false} (! bb11) | br1 -> {_22} (! bb8) ] ]
| bb8 = s0
[ s0 = s1 [ _ck -> (! {[@expl:type invariant] inv_refmut_Sparse_T self} any) ]
| s1 = -{resolve_refmut_Sparse_T self}- s2
| s2 = return {_ret} ]
| bb11 = s0
[ s0 = [ &_27 <- () ] s1
| s1 = {[@expl:assertion] UInt64.t'int self.current.n < UInt64.t'int const_SIZE} s2
| s2 = [ &_33 <- i ] s3
| s3 = [ &_34 <- UInt64.lt _33 const_SIZE ] s4
| s4 = {[@expl:index in bounds] _34} s5
| s5 = Slice64.set <UInt64.t> {self.current.idx} {_33} {self.current.n}
(fun (r: Slice64.array UInt64.t) -> [ &self <- { self with current = { self.current with idx = r } } ] s6)
| s6 = [ &_36 <- self.current.n ] s7
| s7 = [ &_37 <- UInt64.lt _36 const_SIZE ] s8
| s8 = {[@expl:index in bounds] _37} s9
| s9 = Slice64.set <UInt64.t> {self.current.back} {_36} {i}
(fun (r: Slice64.array UInt64.t) -> [ &self <- { self with current = { self.current with back = r } } ] s10)
| s10 = UInt64.add {self.current.n} {(1: UInt64.t)}
(fun (_x: UInt64.t) -> [ &self <- { self with current = { self.current with n = _x } } ] s11)
| s11 = s12 [ _ck -> (! {[@expl:type invariant] inv_refmut_Sparse_T self} any) ]
| s12 = -{resolve_refmut_Sparse_T self}- s13
| s13 = return {_ret} ] ]
[ & _ret: () = Any.any_l ()
| & self: MutBorrow.t t_Sparse_T = self
| & i: UInt64.t = i
| & v: t_T = v
| & _14: UInt64.t = Any.any_l ()
| & _15: bool = Any.any_l ()
| & index: UInt64.t = Any.any_l ()
| & _17: UInt64.t = Any.any_l ()
| & _18: bool = Any.any_l ()
| & _19: bool = Any.any_l ()
| & _22: bool = Any.any_l ()
| & _23: UInt64.t = Any.any_l ()
| & _24: UInt64.t = Any.any_l ()
| & _25: bool = Any.any_l ()
| & _27: () = Any.any_l ()
| & _33: UInt64.t = Any.any_l ()
| & _34: bool = Any.any_l ()
| & _36: UInt64.t = Any.any_l ()
| & _37: bool = Any.any_l () ])
[ return (result: ()) -> {[@stop_split] [@expl:set_T ensures] ([@stop_split] [@expl:set ensures #0] forall j: int. 0
<= j
/\ j < UInt64.t'int const_SIZE /\ j <> UInt64.t'int i
-> Seq.get (view_Sparse_T self.final) j = Seq.get (view_Sparse_T self.current) j)
/\ ([@stop_split] [@expl:set ensures #1] Seq.get (view_Sparse_T self.final) (UInt64.t'int i) = Some v)}
(! return {result}) ]
end
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)