hax-lib 0.4.0

Hax-specific helpers for Rust programs
Documentation
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
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [alloc]: function definitions
import Aeneas
import CoreModels.Core.TypesPrologue
import CoreModels.Core.Types
import CoreModels.RustPrimitives.Types
import CoreModels.Alloc.Types
import CoreModels.RustPrimitives.Funs
import CoreModels.Core.Funs
-- (alloc-side externals live in parent CoreModels.RustPrimitives)
open CoreModels Aeneas
open Aeneas.Std hiding namespace core alloc
open RustM ControlFlow Error
open Std.Do
set_option linter.dupNamespace false
set_option linter.hashCommand false
set_option linter.unusedVariables false
set_option linter.style.whitespace false
set_option linter.style.setOption false
set_option linter.style.longLine false

/- You can set the `maxHeartbeats` value with the `-max-heartbeats` CLI option -/
set_option maxHeartbeats 1000000

/- You can set the `maxRecDepth` value with the `-max-recdepth` CLI option -/
set_option maxRecDepth 2048

namespace CoreModels.alloc

/-- [alloc::alloc::{impl core::clone::Clone for alloc::alloc::Global}::clone]:
    Source: 'src/lib.rs', lines 31:13-31:18
    Visibility: public -/
def alloc.Global.Insts.CoreCloneClone.clone
  (self : alloc.Global) : RustM alloc.Global := do
  ok ()

/-- Trait implementation: [alloc::alloc::{impl core::clone::Clone for alloc::alloc::Global}]
    Source: 'src/lib.rs', lines 31:13-31:18 -/
@[reducible]
impl_def alloc.Global.Insts.CoreCloneClone : core.clone.Clone alloc.Global := {
  clone := alloc.Global.Insts.CoreCloneClone.clone
  clone_from := core.clone.Clone.clone_from.default
    alloc.Global.Insts.CoreCloneClone
}

/-- Trait implementation: [alloc::alloc::{impl alloc::alloc::Allocator for alloc::alloc::Global}]
    Source: 'src/lib.rs', lines 34:4-34:32 -/
@[reducible]
def alloc.Global.Insts.AllocAllocAllocator : alloc.Allocator
  alloc.Global := {
}

/-- [alloc::borrow::{impl alloc::borrow::ToOwned for T}::to_owned]:
    Source: 'src/lib.rs', lines 44:8-46:9
    Visibility: public -/
def borrow.ToOwned.Blanket.to_owned {T : Type} (self : T) : RustM T := do
  ok self

/-- Trait implementation: [alloc::borrow::{impl alloc::borrow::ToOwned for T}]
    Source: 'src/lib.rs', lines 43:4-47:5 -/
@[reducible]
def borrow.ToOwned.Blanket (T : Type) : borrow.ToOwned T := {
  to_owned := borrow.ToOwned.Blanket.to_owned
}

/-- [alloc::boxed::{alloc::boxed::Box<T>}::new]:
    Source: 'src/lib.rs', lines 66:8-68:9 -/
def boxed.Box.new {T : Type} (v : T) : RustM T := do
  ok v

/-- [alloc::boxed::{impl core::ops::deref::Deref<T> for alloc::boxed::Box<T>}::deref]:
    Source: 'src/lib.rs', lines 74:8-76:9
    Visibility: public -/
def boxed.Box.Insts.CoreOpsDerefDeref.deref
  {T : Type} (self : boxed.Box T) : RustM T := do
  ok self

/-- Trait implementation: [alloc::boxed::{impl core::ops::deref::Deref<T> for alloc::boxed::Box<T>}]
    Source: 'src/lib.rs', lines 72:4-77:5 -/
@[reducible]
def boxed.Box.Insts.CoreOpsDerefDeref (T : Type) : core.ops.deref.Deref
  (boxed.Box T) T := {
  deref := boxed.Box.Insts.CoreOpsDerefDeref.deref
}

/-- [alloc::boxed::{impl core::clone::Clone for alloc::boxed::Box<T>}::clone]:
    Source: 'src/lib.rs', lines 81:8-83:9
    Visibility: public -/
def boxed.Box.Insts.CoreCloneClone.clone
  {T : Type} (corecloneCloneInst : core.clone.Clone T) (self : boxed.Box T) :
  RustM (boxed.Box T)
  := do
  let t ← corecloneCloneInst.clone self
  ok t

/-- Trait implementation: [alloc::boxed::{impl core::clone::Clone for alloc::boxed::Box<T>}]
    Source: 'src/lib.rs', lines 80:4-84:5 -/
@[reducible]
impl_def boxed.Box.Insts.CoreCloneClone {T : Type} (corecloneCloneInst :
  core.clone.Clone T) : core.clone.Clone (boxed.Box T) := {
  clone := boxed.Box.Insts.CoreCloneClone.clone corecloneCloneInst
  clone_from := core.clone.Clone.clone_from.default
    (boxed.Box.Insts.CoreCloneClone corecloneCloneInst)
}

/-- [alloc::boxed::{impl core::cmp::PartialEq<alloc::boxed::Box<U>> for alloc::boxed::Box<T>}::eq]:
    Source: 'src/lib.rs', lines 96:8-98:9
    Visibility: public -/
def boxed.Box.Insts.CoreCmpPartialEqBox.eq
  {T : Type} {U : Type} (corecmpPartialEqInst : core.cmp.PartialEq T U)
  (self : boxed.Box T) (other : boxed.Box U) :
  RustM Bool
  := do
  corecmpPartialEqInst.eq self other

/-- [alloc::boxed::{impl core::cmp::PartialEq<alloc::boxed::Box<U>> for alloc::boxed::Box<T>}::ne]:
    Source: 'src/lib.rs', lines 93:8-95:9
    Visibility: public -/
def boxed.Box.Insts.CoreCmpPartialEqBox.ne
  {T : Type} {U : Type} (corecmpPartialEqInst : core.cmp.PartialEq T U)
  (self : boxed.Box T) (other : boxed.Box U) :
  RustM Bool
  := do
  let b ←
    boxed.Box.Insts.CoreCmpPartialEqBox.eq corecmpPartialEqInst self other
  ok (b = false)

/-- Trait implementation: [alloc::boxed::{impl core::cmp::PartialEq<alloc::boxed::Box<U>> for alloc::boxed::Box<T>}]
    Source: 'src/lib.rs', lines 91:4-99:5 -/
@[reducible]
def boxed.Box.Insts.CoreCmpPartialEqBox {T : Type} {U : Type}
  (corecmpPartialEqInst : core.cmp.PartialEq T U) : core.cmp.PartialEq
  (boxed.Box T) (boxed.Box U) := {
  eq := boxed.Box.Insts.CoreCmpPartialEqBox.eq corecmpPartialEqInst
  ne := boxed.Box.Insts.CoreCmpPartialEqBox.ne corecmpPartialEqInst
}

/-- [alloc::collections::btree::set::{alloc::collections::btree::set::BTreeSet<T, U>}::new]:
    Source: 'src/lib.rs', lines 296:16-298:17 -/
def collections.btree.set.BTreeSet.new
  (T : Type) (U : Type) : RustM (collections.btree.set.BTreeSet T U) := do
  ok (core.option.Option.None, core.option.Option.None)

/-- [alloc::collections::vec_deque::{alloc::collections::vec_deque::VecDeque<T, alloc::alloc::Global>}::new]:
    Source: 'src/lib.rs', lines 312:12-314:13 -/
def collections.vec_deque.VecDequeTGlobal.new
  (T : Type) : RustM (collections.vec_deque.VecDeque T alloc.Global) := do
  let s ← rust_primitives.sequence.seq_empty T
  ok (s, core.marker.PhantomData.mk)

/-- [alloc::collections::vec_deque::{alloc::collections::vec_deque::VecDeque<T, alloc::alloc::Global>}::with_capacity]:
    Source: 'src/lib.rs', lines 315:12-317:13 -/
def collections.vec_deque.VecDequeTGlobal.with_capacity
  (T : Type) (_capacity : Std.Usize) :
  RustM (collections.vec_deque.VecDeque T alloc.Global)
  := do
  collections.vec_deque.VecDequeTGlobal.new T

/-- [alloc::collections::vec_deque::{alloc::collections::vec_deque::VecDeque<T, A>}::push_back]:
    Source: 'src/lib.rs', lines 323:12-325:13 -/
def collections.vec_deque.VecDeque.push_back
  {T : Type} {A : Type} (self : collections.vec_deque.VecDeque T A) (x : T) :
  RustM (collections.vec_deque.VecDeque T A)
  := do
  let (s, pd) := self
  let s1 ← rust_primitives.sequence.seq_push s x
  ok (s1, pd)

/-- [alloc::collections::vec_deque::{alloc::collections::vec_deque::VecDeque<T, A>}::len]:
    Source: 'src/lib.rs', lines 326:12-328:13 -/
def collections.vec_deque.VecDeque.len
  {T : Type} {A : Type} (self : collections.vec_deque.VecDeque T A) :
  RustM Std.Usize
  := do
  let (s, _) := self
  rust_primitives.sequence.seq_len s

/-- [alloc::collections::vec_deque::{alloc::collections::vec_deque::VecDeque<T, A>}::pop_front]:
    Source: 'src/lib.rs', lines 329:12-335:13 -/
def collections.vec_deque.VecDeque.pop_front
  {T : Type} {A : Type} (self : collections.vec_deque.VecDeque T A) :
  RustM ((core.option.Option T) × (collections.vec_deque.VecDeque T A))
  := do
  let i ← collections.vec_deque.VecDeque.len self
  if i = 0#usize
  then ok (core.option.Option.None, self)
  else
    let (s, pd) := self
    let (t, s1) ← rust_primitives.sequence.seq_remove s 0#usize
    ok (core.option.Option.Some t, (s1, pd))

/-- [alloc::collections::vec_deque::{impl core::ops::index::Index<usize, T> for alloc::collections::vec_deque::VecDeque<T, A>}::index]:
    Source: 'src/lib.rs', lines 342:12-344:13
    Visibility: public -/
def collections.vec_deque.VecDeque.Insts.CoreOpsIndexIndexUsizeT.index
  {T : Type} {A : Type} (self : collections.vec_deque.VecDeque T A)
  (i : Std.Usize) :
  RustM T
  := do
  let (s, _) := self
  rust_primitives.sequence.seq_index s i

/-- Trait implementation: [alloc::collections::vec_deque::{impl core::ops::index::Index<usize, T> for alloc::collections::vec_deque::VecDeque<T, A>}]
    Source: 'src/lib.rs', lines 339:8-345:9 -/
@[reducible]
def collections.vec_deque.VecDeque.Insts.CoreOpsIndexIndexUsizeT (T : Type) (A
  : Type) : core.ops.index.Index (collections.vec_deque.VecDeque T A) Std.Usize
  T := {
  index := collections.vec_deque.VecDeque.Insts.CoreOpsIndexIndexUsizeT.index
}

/-- [alloc::collections::vec_deque::into_iter::{impl core::iter::traits::iterator::Iterator<T> for alloc::collections::vec_deque::into_iter::IntoIter<T, A>}::next]:
    Source: 'src/lib.rs', lines 352:16-358:17
    Visibility: public -/
def
  collections.vec_deque.into_iter.IntoIter.Insts.CoreIterTraitsIteratorIterator.next
  {T : Type} {A : Type} (self : collections.vec_deque.into_iter.IntoIter T A) :
  RustM ((core.option.Option T) × (collections.vec_deque.into_iter.IntoIter T
    A))
  := do
  let (s, pd) := self
  let i ← rust_primitives.sequence.seq_len s
  if i = 0#usize
  then ok (core.option.Option.None, self)
  else
    let (t, s1) ← rust_primitives.sequence.seq_remove s 0#usize
    ok (core.option.Option.Some t, (s1, pd))

/-- Trait implementation: [alloc::collections::vec_deque::into_iter::{impl core::iter::traits::iterator::Iterator<T> for alloc::collections::vec_deque::into_iter::IntoIter<T, A>}]
    Source: 'src/lib.rs', lines 350:12-359:13 -/
@[reducible]
def
  collections.vec_deque.into_iter.IntoIter.Insts.CoreIterTraitsIteratorIterator
  (T : Type) (A : Type) : core.iter.traits.iterator.Iterator
  (collections.vec_deque.into_iter.IntoIter T A) T := {
  next :=
    collections.vec_deque.into_iter.IntoIter.Insts.CoreIterTraitsIteratorIterator.next
}

/-- [alloc::collections::vec_deque::{impl core::iter::traits::collect::IntoIterator<T, alloc::collections::vec_deque::into_iter::IntoIter<T, A>> for alloc::collections::vec_deque::VecDeque<T, A>}::into_iter]:
    Source: 'src/lib.rs', lines 366:12-368:13
    Visibility: public -/
def
  collections.vec_deque.VecDeque.Insts.CoreIterTraitsCollectIntoIteratorTIntoIter.into_iter
  {T : Type} {A : Type} (self : collections.vec_deque.VecDeque T A) :
  RustM (collections.vec_deque.into_iter.IntoIter T A)
  := do
  let (s, _) := self
  ok (s, core.marker.PhantomData.mk)

/-- Trait implementation: [alloc::collections::vec_deque::{impl core::iter::traits::collect::IntoIterator<T, alloc::collections::vec_deque::into_iter::IntoIter<T, A>> for alloc::collections::vec_deque::VecDeque<T, A>}]
    Source: 'src/lib.rs', lines 363:8-369:9 -/
@[reducible]
def
  collections.vec_deque.VecDeque.Insts.CoreIterTraitsCollectIntoIteratorTIntoIter
  (T : Type) (A : Type) : core.iter.traits.collect.IntoIterator
  (collections.vec_deque.VecDeque T A) T
  (collections.vec_deque.into_iter.IntoIter T A) := {
  iteratorIteratorInst :=
    collections.vec_deque.into_iter.IntoIter.Insts.CoreIterTraitsIteratorIterator
    T A
  into_iter :=
    collections.vec_deque.VecDeque.Insts.CoreIterTraitsCollectIntoIteratorTIntoIter.into_iter
}

/-- [alloc::vec::from_seq]:
    Source: 'src/lib.rs', lines 729:4-731:5 -/
def vec.from_seq
  {T : Type} (s : rust_primitives.sequence.Seq T) : RustM (vec.Vec T) := do
  ok s

/-- [alloc::slice::{alloc::slice::Dummy<T>}::to_vec]:
    Source: 'src/lib.rs', lines 514:8-521:9 -/
def slice.Dummy.to_vec
  {T : Type} (corecloneCloneInst : core.clone.Clone T) (s : Slice T) :
  RustM (vec.Vec T)
  := do
  let seq ← rust_primitives.sequence.seq_empty T
  let seq1 ← rust_primitives.sequence.seq_extend corecloneCloneInst seq s
  vec.from_seq seq1

/-- [alloc::slice::{alloc::slice::Dummy<T>}::into_vec]:
    Source: 'src/lib.rs', lines 523:8-525:9 -/
def slice.Dummy.into_vec {T : Type} (s : Slice T) : RustM (vec.Vec T) := do
  let s1 ← rust_primitives.sequence.seq_from_boxed_slice s
  vec.from_seq s1

/-- [alloc::slice::{alloc::slice::Dummy<T>}::concat]: loop body 0:
    Source: 'src/lib.rs', lines 538:12-541:13 -/
@[rust_loop_body]
def slice.Dummy.concat_loop.body
  {T : Type} {Item : Type} (corecloneCloneInst : core.clone.Clone Item)
  (coreborrowBorrowTSliceInst : core.borrow.Borrow T (Slice Item))
  (s : Slice T) (out : rust_primitives.sequence.Seq Item) (i : Std.Usize) :
  RustM (ControlFlow ((rust_primitives.sequence.Seq Item) × Std.Usize)
    (rust_primitives.sequence.Seq Item))
  := do
  let i1 ← rust_primitives.slice.slice_length s
  if i < i1
  then
    let t ← rust_primitives.slice.slice_index s i
    let s1 ← coreborrowBorrowTSliceInst.borrow t
    let out1 ← rust_primitives.sequence.seq_extend corecloneCloneInst out s1
    let i2 ← i + 1#usize
    ok (cont (out1, i2))
  else ok (done out)

/-- [alloc::slice::{alloc::slice::Dummy<T>}::concat]: loop 0:
    Source: 'src/lib.rs', lines 538:12-541:13 -/
@[rust_loop]
def slice.Dummy.concat_loop
  {T : Type} {Item : Type} (corecloneCloneInst : core.clone.Clone Item)
  (coreborrowBorrowTSliceInst : core.borrow.Borrow T (Slice Item))
  (s : Slice T) (out : rust_primitives.sequence.Seq Item) (i : Std.Usize) :
  RustM (rust_primitives.sequence.Seq Item)
  := do
  loop
    (fun (out1, i1) => slice.Dummy.concat_loop.body corecloneCloneInst
      coreborrowBorrowTSliceInst s out1 i1)
    (out, i)

/-- [alloc::slice::{alloc::slice::Dummy<T>}::concat]:
    Source: 'src/lib.rs', lines 532:8-543:9 -/
def slice.Dummy.concat
  {T : Type} {Item : Type} (corecloneCloneInst : core.clone.Clone Item)
  (coreborrowBorrowTSliceInst : core.borrow.Borrow T (Slice Item))
  (s : Slice T) :
  RustM (vec.Vec Item)
  := do
  let out ← rust_primitives.sequence.seq_empty Item
  let out1 ←
    slice.Dummy.concat_loop corecloneCloneInst coreborrowBorrowTSliceInst s out
      0#usize
  vec.from_seq out1

/-- [alloc::vec::{alloc::vec::Vec<T>}::as_slice]:
    Source: 'src/lib.rs', lines 844:8-846:9
    Visibility: public -/
def vec.Vec.as_slice {T : Type} (self : vec.Vec T) : RustM (Slice T) := do
  rust_primitives.sequence.seq_to_slice self

/-- [alloc::vec::{impl core::ops::deref::Deref<[T]> for alloc::vec::Vec<T>}::deref]:
    Source: 'src/lib.rs', lines 997:8-999:9
    Visibility: public -/
def vec.Vec.Insts.CoreOpsDerefDerefSlice.deref
  {T : Type} (self : vec.Vec T) : RustM (Slice T) := do
  vec.Vec.as_slice self

/-- [alloc::vec::{impl core::clone::Clone for alloc::vec::Vec<T>}::clone]: loop body 0:
    Source: 'src/lib.rs', lines 736:12-738:13
    Visibility: public -/
@[rust_loop_body]
def vec.Vec.Insts.CoreCloneClone.clone_loop.body
  {T : Type} (corecloneCloneInst : core.clone.Clone T)
  (iter_ : core.slice.iter.Iter T) (new_vec : rust_primitives.sequence.Seq T) :
  RustM (ControlFlow ((core.slice.iter.Iter T) × (rust_primitives.sequence.Seq
    T)) (rust_primitives.sequence.Seq T))
  := do
  let (o, iter1) ←
    core.slice.iter.Iter.Insts.CoreIterTraitsIteratorIteratorSharedAT.next iter_
  match o with
  | core.option.Option.None => ok (done new_vec)
  | core.option.Option.Some it =>
    let t ← corecloneCloneInst.clone it
    let new_vec1 ← rust_primitives.sequence.seq_push new_vec t
    ok (cont (iter1, new_vec1))

/-- [alloc::vec::{impl core::clone::Clone for alloc::vec::Vec<T>}::clone]: loop 0:
    Source: 'src/lib.rs', lines 736:12-738:13
    Visibility: public -/
@[rust_loop]
def vec.Vec.Insts.CoreCloneClone.clone_loop
  {T : Type} (corecloneCloneInst : core.clone.Clone T)
  (iter_ : core.slice.iter.Iter T) (new_vec : rust_primitives.sequence.Seq T) :
  RustM (rust_primitives.sequence.Seq T)
  := do
  loop
    (fun (iter1, new_vec1) => vec.Vec.Insts.CoreCloneClone.clone_loop.body
      corecloneCloneInst iter1 new_vec1)
    (iter_, new_vec)

/-- [alloc::vec::{impl core::clone::Clone for alloc::vec::Vec<T>}::clone]:
    Source: 'src/lib.rs', lines 734:8-740:9
    Visibility: public -/
def vec.Vec.Insts.CoreCloneClone.clone
  {T : Type} (corecloneCloneInst : core.clone.Clone T) (self : vec.Vec T) :
  RustM (vec.Vec T)
  := do
  let new_vec ← rust_primitives.sequence.seq_empty T
  let s ← vec.Vec.Insts.CoreOpsDerefDerefSlice.deref self
  let iter ← core.slice.Slice.iter s
  let new_vec1 ←
    vec.Vec.Insts.CoreCloneClone.clone_loop corecloneCloneInst iter new_vec
  ok new_vec1

/-- Trait implementation: [alloc::vec::{impl core::clone::Clone for alloc::vec::Vec<T>}]
    Source: 'src/lib.rs', lines 733:4-741:5 -/
@[reducible]
impl_def vec.Vec.Insts.CoreCloneClone {T : Type} (corecloneCloneInst :
  core.clone.Clone T) : core.clone.Clone (vec.Vec T) := {
  clone := vec.Vec.Insts.CoreCloneClone.clone corecloneCloneInst
  clone_from := core.clone.Clone.clone_from.default
    (vec.Vec.Insts.CoreCloneClone corecloneCloneInst)
}

/-- [alloc::vec::{impl core::ops::index::Index<I, Clause0_Output> for alloc::vec::Vec<T>}::index]:
    Source: 'src/lib.rs', lines 972:8-974:9
    Visibility: public -/
def vec.Vec.Insts.CoreOpsIndexIndex.index
  {T : Type} {I : Type} {Clause0_Output : Type}
  (coresliceindexSliceIndexISliceClause0_OutputInst :
  core.slice.index.SliceIndex I (Slice T) Clause0_Output) (self : vec.Vec T)
  (i : I) :
  RustM Clause0_Output
  := do
  let s ← vec.Vec.Insts.CoreOpsDerefDerefSlice.deref self
  core.Slice.Insts.CoreOpsIndexIndex.index
    coresliceindexSliceIndexISliceClause0_OutputInst s i

/-- [alloc::vec::{alloc::vec::Vec<T>}::len]:
    Source: 'src/lib.rs', lines 818:8-820:9
    Visibility: public -/
def vec.Vec.len {T : Type} (self : vec.Vec T) : RustM Std.Usize := do
  rust_primitives.sequence.seq_len self

/-- [alloc::vec::{impl core::cmp::PartialEq<alloc::vec::Vec<U>> for alloc::vec::Vec<T>}::eq]: loop body 0:
    Source: 'src/lib.rs', lines 1:0-762:17
    Visibility: public -/
@[rust_loop_body]
def vec.Vec.Insts.CoreCmpPartialEqVec.eq_loop.body
  {T : Type} {U : Type} (corecmpPartialEqInst : core.cmp.PartialEq T U)
  (self : vec.Vec T) (other : vec.Vec U)
  (iter_ : core.ops.range.Range Std.Usize) (res : Bool) :
  RustM (ControlFlow ((core.ops.range.Range Std.Usize) × Bool) Bool)
  := do
  let (o, iter1) ←
    core.ops.range.Range.Insts.CoreIterTraitsIteratorIterator.next
      core.Usize.Insts.CoreIterRangeStep iter_
  match o with
  | core.option.Option.None => ok (done res)
  | core.option.Option.Some i =>
    if res
    then
      let t ←
        vec.Vec.Insts.CoreOpsIndexIndex.index
          (core.Usize.Insts.CoreSliceIndexSliceIndexSliceT T) self i
      let t1 ←
        vec.Vec.Insts.CoreOpsIndexIndex.index
          (core.Usize.Insts.CoreSliceIndexSliceIndexSliceT U) other i
      let b ← corecmpPartialEqInst.eq t t1
      if b
      then ok (cont (iter1, true))
      else ok (cont (iter1, false))
    else ok (cont (iter1, false))

/-- [alloc::vec::{impl core::cmp::PartialEq<alloc::vec::Vec<U>> for alloc::vec::Vec<T>}::eq]: loop 0:
    Source: 'src/lib.rs', lines 1:0-762:17
    Visibility: public -/
@[rust_loop]
def vec.Vec.Insts.CoreCmpPartialEqVec.eq_loop
  {T : Type} {U : Type} (corecmpPartialEqInst : core.cmp.PartialEq T U)
  (iter_ : core.ops.range.Range Std.Usize) (self : vec.Vec T)
  (other : vec.Vec U) (res : Bool) :
  RustM Bool
  := do
  loop
    (fun (iter1, res1) => vec.Vec.Insts.CoreCmpPartialEqVec.eq_loop.body
      corecmpPartialEqInst self other iter1 res1)
    (iter_, res)

/-- [alloc::vec::{impl core::cmp::PartialEq<alloc::vec::Vec<U>> for alloc::vec::Vec<T>}::eq]:
    Source: 'src/lib.rs', lines 750:8-765:9
    Visibility: public -/
def vec.Vec.Insts.CoreCmpPartialEqVec.eq
  {T : Type} {U : Type} (corecmpPartialEqInst : core.cmp.PartialEq T U)
  (self : vec.Vec T) (other : vec.Vec U) :
  RustM Bool
  := do
  let i ← vec.Vec.len self
  let i1 ← vec.Vec.len other
  if i = i1
  then
    vec.Vec.Insts.CoreCmpPartialEqVec.eq_loop corecmpPartialEqInst
      { start := 0#usize, «end» := i } self other true
  else ok false

/-- [alloc::vec::{impl core::cmp::PartialEq<alloc::vec::Vec<U>> for alloc::vec::Vec<T>}::ne]:
    Source: 'src/lib.rs', lines 747:8-749:9
    Visibility: public -/
def vec.Vec.Insts.CoreCmpPartialEqVec.ne
  {T : Type} {U : Type} (corecmpPartialEqInst : core.cmp.PartialEq T U)
  (self : vec.Vec T) (other : vec.Vec U) :
  RustM Bool
  := do
  let b ←
    vec.Vec.Insts.CoreCmpPartialEqVec.eq corecmpPartialEqInst self other
  ok (b = false)

/-- Trait implementation: [alloc::vec::{impl core::cmp::PartialEq<alloc::vec::Vec<U>> for alloc::vec::Vec<T>}]
    Source: 'src/lib.rs', lines 742:4-766:5 -/
@[reducible]
def vec.Vec.Insts.CoreCmpPartialEqVec {T : Type} {U : Type}
  (corecmpPartialEqInst : core.cmp.PartialEq T U) : core.cmp.PartialEq (vec.Vec
  T) (vec.Vec U) := {
  eq := vec.Vec.Insts.CoreCmpPartialEqVec.eq corecmpPartialEqInst
  ne := vec.Vec.Insts.CoreCmpPartialEqVec.ne corecmpPartialEqInst
}

/-- [alloc::vec::into_iter::{impl core::iter::traits::iterator::Iterator<T> for alloc::vec::into_iter::IntoIter<T>}::next]:
    Source: 'src/lib.rs', lines 777:12-783:13
    Visibility: public -/
def vec.into_iter.IntoIter.Insts.CoreIterTraitsIteratorIterator.next
  {T : Type} (self : vec.into_iter.IntoIter T) :
  RustM ((core.option.Option T) × (vec.into_iter.IntoIter T))
  := do
  let i ← rust_primitives.sequence.seq_len self
  if i = 0#usize
  then ok (core.option.Option.None, self)
  else
    let (t, s) ← rust_primitives.sequence.seq_remove self 0#usize
    ok (core.option.Option.Some t, s)

/-- Trait implementation: [alloc::vec::into_iter::{impl core::iter::traits::iterator::Iterator<T> for alloc::vec::into_iter::IntoIter<T>}]
    Source: 'src/lib.rs', lines 775:8-784:9 -/
@[reducible]
def vec.into_iter.IntoIter.Insts.CoreIterTraitsIteratorIterator (T : Type) :
  core.iter.traits.iterator.Iterator (vec.into_iter.IntoIter T) T := {
  next := vec.into_iter.IntoIter.Insts.CoreIterTraitsIteratorIterator.next
}

/-- [alloc::vec::{impl core::iter::traits::collect::IntoIterator<T, alloc::vec::into_iter::IntoIter<T>> for alloc::vec::Vec<T>}::into_iter]:
    Source: 'src/lib.rs', lines 790:8-792:9
    Visibility: public -/
def vec.Vec.Insts.CoreIterTraitsCollectIntoIteratorTIntoIter.into_iter
  {T : Type} (self : vec.Vec T) : RustM (vec.into_iter.IntoIter T) := do
  ok self

/-- Trait implementation: [alloc::vec::{impl core::iter::traits::collect::IntoIterator<T, alloc::vec::into_iter::IntoIter<T>> for alloc::vec::Vec<T>}]
    Source: 'src/lib.rs', lines 787:4-793:5 -/
@[reducible]
def vec.Vec.Insts.CoreIterTraitsCollectIntoIteratorTIntoIter (T : Type) :
  core.iter.traits.collect.IntoIterator (vec.Vec T) T (vec.into_iter.IntoIter
  T) := {
  iteratorIteratorInst :=
    vec.into_iter.IntoIter.Insts.CoreIterTraitsIteratorIterator T
  into_iter :=
    vec.Vec.Insts.CoreIterTraitsCollectIntoIteratorTIntoIter.into_iter
}

/-- [alloc::vec::from_elem]:
    Source: 'src/lib.rs', lines 795:4-797:5 -/
def vec.from_elem
  {T : Type} (corecloneCloneInst : core.clone.Clone T) (item : T)
  (len : Std.Usize) :
  RustM (vec.Vec T)
  := do
  let s ← rust_primitives.sequence.seq_create corecloneCloneInst item len
  ok s

/-- [alloc::vec::{alloc::vec::Vec<T>}::new]:
    Source: 'src/lib.rs', lines 801:8-803:9
    Visibility: public -/
def vec.Vec.new (T : Type) : RustM (vec.Vec T) := do
  let s ← rust_primitives.sequence.seq_empty T
  ok s

/-- [alloc::vec::{alloc::vec::Vec<T>}::with_capacity]:
    Source: 'src/lib.rs', lines 804:8-806:9
    Visibility: public -/
def vec.Vec.with_capacity (T : Type) (_c : Std.Usize) : RustM (vec.Vec T) := do
  vec.Vec.new T

/-- [alloc::vec::{impl core::default::Default for alloc::vec::Vec<T>}::default]:
    Source: 'src/lib.rs', lines 811:8-813:9
    Visibility: public -/
def vec.Vec.Insts.CoreDefaultDefault.default
  (T : Type) : RustM (vec.Vec T) := do
  vec.Vec.new T

/-- Trait implementation: [alloc::vec::{impl core::default::Default for alloc::vec::Vec<T>}]
    Source: 'src/lib.rs', lines 810:4-814:5 -/
@[reducible]
def vec.Vec.Insts.CoreDefaultDefault (T : Type) : core.default.Default (vec.Vec
  T) := {
  default := vec.Vec.Insts.CoreDefaultDefault.default T
}

/-- [alloc::vec::{alloc::vec::Vec<T>}::push]:
    Source: 'src/lib.rs', lines 822:8-824:9
    Visibility: public -/
def vec.Vec.push
  {T : Type} (self : vec.Vec T) (x : T) : RustM (vec.Vec T) := do
  let s ← rust_primitives.sequence.seq_push self x
  ok s

/-- [alloc::vec::{alloc::vec::Vec<T>}::pop]:
    Source: 'src/lib.rs', lines 825:8-833:9
    Visibility: public -/
def vec.Vec.pop
  {T : Type} (self : vec.Vec T) :
  RustM ((core.option.Option T) × (vec.Vec T))
  := do
  let l ← rust_primitives.sequence.seq_len self
  if l > 0#usize
  then
    let i ← l - 1#usize
    let (last, s) ← rust_primitives.sequence.seq_remove self i
    ok (core.option.Option.Some last, s)
  else ok (core.option.Option.None, self)

/-- [alloc::vec::{alloc::vec::Vec<T>}::is_empty]:
    Source: 'src/lib.rs', lines 834:8-836:9
    Visibility: public -/
def vec.Vec.is_empty {T : Type} (self : vec.Vec T) : RustM Bool := do
  let i ← rust_primitives.sequence.seq_len self
  ok (i = 0#usize)

/-- [alloc::vec::{alloc::vec::Vec<T>}::insert]:
    Source: 'src/lib.rs', lines 838:8-843:9
    Visibility: public -/
def vec.Vec.insert
  {T : Type} (self : vec.Vec T) (index : Std.Usize) (element : T) :
  RustM (vec.Vec T)
  := do
  let l ← rust_primitives.sequence.seq_len self
  let (right, s) ← rust_primitives.sequence.seq_drain self index l
  let s1 ← rust_primitives.sequence.seq_push s element
  let (s2, _) ← rust_primitives.sequence.seq_concat s1 right
  ok s2

/-- [alloc::vec::{alloc::vec::Vec<T>}::as_mut_slice]:
    Source: 'src/lib.rs', lines 850:8-852:9
    Visibility: public -/
def vec.Vec.as_mut_slice
  {T : Type} (self : vec.Vec T) :
  RustM ((Slice T) × (Slice T → vec.Vec T))
  := do
  let (s, seq_to_slice_mut_back) ←
    rust_primitives.sequence.seq_to_slice_mut self
  let back := fun s1 => let s2 := seq_to_slice_mut_back s1
                        s2
  ok (s, back)

/-- [alloc::vec::{alloc::vec::Vec<T>}::truncate]:
    Source: 'src/lib.rs', lines 856:8-861:9
    Visibility: public -/
def vec.Vec.truncate
  {T : Type} (self : vec.Vec T) (n : Std.Usize) : RustM (vec.Vec T) := do
  let l ← rust_primitives.sequence.seq_len self
  if n < l
  then let (_, s) ← rust_primitives.sequence.seq_drain self n l
       ok s
  else ok self

/-- [alloc::vec::{alloc::vec::Vec<T>}::swap_remove]:
    Source: 'src/lib.rs', lines 864:8-874:9
    Visibility: public -/
def vec.Vec.swap_remove
  {T : Type} (self : vec.Vec T) (n : Std.Usize) :
  RustM (T × (vec.Vec T))
  := do
  let l ← rust_primitives.sequence.seq_len self
  let i ← l - 1#usize
  let (last, s) ← rust_primitives.sequence.seq_remove self i
  if n = i
  then ok (last, s)
  else
    let (removed, s1) ← rust_primitives.sequence.seq_remove s n
    let self1 ← vec.Vec.insert s1 n last
    ok (removed, self1)

/-- [alloc::vec::{alloc::vec::Vec<T>}::remove]:
    Source: 'src/lib.rs', lines 881:8-883:9
    Visibility: public -/
def vec.Vec.remove
  {T : Type} (self : vec.Vec T) (index : Std.Usize) :
  RustM (T × (vec.Vec T))
  := do
  let (t, s) ← rust_primitives.sequence.seq_remove self index
  ok (t, s)

/-- [alloc::vec::{alloc::vec::Vec<T>}::clear]:
    Source: 'src/lib.rs', lines 885:8-887:9
    Visibility: public -/
def vec.Vec.clear {T : Type} (self : vec.Vec T) : RustM (vec.Vec T) := do
  let s ← rust_primitives.sequence.seq_empty T
  ok s

/-- [alloc::vec::{alloc::vec::Vec<T>}::append]:
    Source: 'src/lib.rs', lines 889:8-892:9
    Visibility: public -/
def vec.Vec.append
  {T : Type} (self : vec.Vec T) (other : vec.Vec T) :
  RustM ((vec.Vec T) × (vec.Vec T))
  := do
  let (s, _) ← rust_primitives.sequence.seq_concat self other
  let s1 ← rust_primitives.sequence.seq_empty T
  ok (s, s1)

/-- [alloc::vec::{alloc::vec::Vec<T>}::split_off]:
    Source: 'src/lib.rs', lines 896:8-899:9
    Visibility: public -/
def vec.Vec.split_off
  {T : Type} (self : vec.Vec T) («at» : Std.Usize) :
  RustM ((vec.Vec T) × (vec.Vec T))
  := do
  let l ← rust_primitives.sequence.seq_len self
  let (s, s1) ← rust_primitives.sequence.seq_drain self «at» l
  ok (s, s1)

/-- [alloc::vec::drain::{impl core::iter::traits::iterator::Iterator<T> for alloc::vec::drain::Drain<T, A>}::next]:
    Source: 'src/lib.rs', lines 917:12-924:13
    Visibility: public -/
def vec.drain.Drain.Insts.CoreIterTraitsIteratorIterator.next
  {T : Type} {A : Type} (self : vec.drain.Drain T A) :
  RustM ((core.option.Option T) × (vec.drain.Drain T A))
  := do
  let (s, pd) := self
  let i ← rust_primitives.sequence.seq_len s
  if i = 0#usize
  then ok (core.option.Option.None, self)
  else
    let (res, s1) ← rust_primitives.sequence.seq_remove s 0#usize
    ok (core.option.Option.Some res, (s1, pd))

/-- Trait implementation: [alloc::vec::drain::{impl core::iter::traits::iterator::Iterator<T> for alloc::vec::drain::Drain<T, A>}]
    Source: 'src/lib.rs', lines 915:8-925:9 -/
@[reducible]
def vec.drain.Drain.Insts.CoreIterTraitsIteratorIterator (T : Type) (A : Type)
  : core.iter.traits.iterator.Iterator (vec.drain.Drain T A) T := {
  next := vec.drain.Drain.Insts.CoreIterTraitsIteratorIterator.next
}

/-- [alloc::vec::{alloc::vec::Vec<T>}::extend_from_slice]:
    Source: 'src/lib.rs', lines 935:8-937:9 -/
def vec.Vec.extend_from_slice
  {T : Type} (corecloneCloneInst : core.clone.Clone T) (self : vec.Vec T)
  (other : Slice T) :
  RustM (vec.Vec T)
  := do
  let s ← rust_primitives.sequence.seq_extend corecloneCloneInst self other
  ok s

/-- [alloc::vec::{alloc::vec::Vec<T>}::resize]:
    Source: 'src/lib.rs', lines 942:8-950:9
    Visibility: public -/
def vec.Vec.resize
  {T : Type} (corecloneCloneInst : core.clone.Clone T) (self : vec.Vec T)
  (new_size : Std.Usize) (value : T) :
  RustM (vec.Vec T)
  := do
  let l ← rust_primitives.sequence.seq_len self
  if new_size > l
  then
    let i ← new_size - l
    let extra ←
      rust_primitives.sequence.seq_create corecloneCloneInst value i
    let (s, _) ← rust_primitives.sequence.seq_concat self extra
    ok s
  else let (_, s) ← rust_primitives.sequence.seq_drain self new_size l
       ok s

/-- Trait implementation: [alloc::vec::{impl core::ops::index::Index<I, Clause0_Output> for alloc::vec::Vec<T>}]
    Source: 'src/lib.rs', lines 966:4-975:5 -/
@[reducible]
def vec.Vec.Insts.CoreOpsIndexIndex {T : Type} {I : Type} {Clause0_Output :
  Type} (coresliceindexSliceIndexISliceClause0_OutputInst :
  core.slice.index.SliceIndex I (Slice T) Clause0_Output) :
  core.ops.index.Index (vec.Vec T) I Clause0_Output := {
  index := vec.Vec.Insts.CoreOpsIndexIndex.index
    coresliceindexSliceIndexISliceClause0_OutputInst
}

/-- [alloc::vec::{impl core::ops::index::IndexMut<I, Clause0_Output> for alloc::vec::Vec<T>}::index_mut]:
    Source: 'src/lib.rs', lines 988:8-990:9
    Visibility: public -/
def vec.Vec.Insts.CoreOpsIndexIndexMut.index_mut
  {T : Type} {I : Type} {Clause0_Output : Type}
  (coresliceindexSliceIndexISliceClause0_OutputInst :
  core.slice.index.SliceIndex I (Slice T) Clause0_Output) (self : vec.Vec T)
  (i : I) :
  RustM (Clause0_Output × (Clause0_Output → vec.Vec T))
  := do
  let (s, seq_to_slice_mut_back) ←
    rust_primitives.sequence.seq_to_slice_mut self
  let (t, index_mut_back) ←
    core.Slice.Insts.CoreOpsIndexIndexMut.index_mut
      coresliceindexSliceIndexISliceClause0_OutputInst s i
  let back :=
    fun t1 => let s1 := index_mut_back t1
              let s2 := seq_to_slice_mut_back s1
              s2
  ok (t, back)

/-- Trait implementation: [alloc::vec::{impl core::ops::index::IndexMut<I, Clause0_Output> for alloc::vec::Vec<T>}]
    Source: 'src/lib.rs', lines 982:4-991:5 -/
@[reducible]
def vec.Vec.Insts.CoreOpsIndexIndexMut {T : Type} {I : Type} {Clause0_Output :
  Type} (coresliceindexSliceIndexISliceClause0_OutputInst :
  core.slice.index.SliceIndex I (Slice T) Clause0_Output) :
  core.ops.index.IndexMut (vec.Vec T) I Clause0_Output := {
  IndexInst := vec.Vec.Insts.CoreOpsIndexIndex
    coresliceindexSliceIndexISliceClause0_OutputInst
  index_mut := vec.Vec.Insts.CoreOpsIndexIndexMut.index_mut
    coresliceindexSliceIndexISliceClause0_OutputInst
}

/-- Trait implementation: [alloc::vec::{impl core::ops::deref::Deref<[T]> for alloc::vec::Vec<T>}]
    Source: 'src/lib.rs', lines 994:4-1000:5 -/
@[reducible]
def vec.Vec.Insts.CoreOpsDerefDerefSlice (T : Type) : core.ops.deref.Deref
  (vec.Vec T) (Slice T) := {
  deref := vec.Vec.Insts.CoreOpsDerefDerefSlice.deref
}

/-- [alloc::vec::{impl core::ops::deref::DerefMut<[T]> for alloc::vec::Vec<T>}::deref_mut]:
    Source: 'src/lib.rs', lines 1007:8-1009:9
    Visibility: public -/
def vec.Vec.Insts.CoreOpsDerefDerefMutSlice.deref_mut
  {T : Type} (self : vec.Vec T) :
  RustM ((Slice T) × (Slice T → vec.Vec T))
  := do
  vec.Vec.as_mut_slice self

/-- Trait implementation: [alloc::vec::{impl core::ops::deref::DerefMut<[T]> for alloc::vec::Vec<T>}]
    Source: 'src/lib.rs', lines 1006:4-1010:5 -/
@[reducible]
def vec.Vec.Insts.CoreOpsDerefDerefMutSlice (T : Type) :
  core.ops.deref.DerefMut (vec.Vec T) (Slice T) := {
  DerefInst := vec.Vec.Insts.CoreOpsDerefDerefSlice T
  deref_mut := vec.Vec.Insts.CoreOpsDerefDerefMutSlice.deref_mut
}

/-- [alloc::vec::{impl core::convert::From<[T; N]> for alloc::vec::Vec<T>}::from]:
    Source: 'src/lib.rs', lines 1014:8-1016:9
    Visibility: public -/
def vec.Vec.Insts.CoreConvertFromArray.from
  {T : Type} {N : Std.Usize} (a : Array T N) : RustM (vec.Vec T) := do
  let s ← rust_primitives.sequence.seq_from_array a
  ok s

/-- Trait implementation: [alloc::vec::{impl core::convert::From<[T; N]> for alloc::vec::Vec<T>}]
    Source: 'src/lib.rs', lines 1013:4-1017:5 -/
@[reducible]
def vec.Vec.Insts.CoreConvertFromArray (T : Type) (N : Std.Usize) :
  core.convert.From (vec.Vec T) (Array T N) := {
  «from» := vec.Vec.Insts.CoreConvertFromArray.from
}

end CoreModels.alloc