@@ -118,7 +118,7 @@ object List {
118
118
// @formatter:off
119
119
1 ( l ≡ List .Cons [T ](value, next) ) by Premise , // auto-generated
120
120
2 ( next.length >= 0 ) by Premise , // auto-generated
121
- 3 ( l.length ≡ (1 + next.length) ) by Simpl ,
121
+ 3 ( l.length ≡ (1 + next.length) ) by Simpl , // Auto,
122
122
4 ( l.length >= 0 ) by Auto and (2 , 3 )
123
123
// @formatter:on
124
124
)
@@ -128,7 +128,7 @@ object List {
128
128
Deduce (
129
129
// @formatter:off
130
130
1 ( l ≡ List .Nil [T ]() ) by Premise , // auto-generated
131
- 2 ( l.length >= 0 ) by Simpl
131
+ 2 ( l.length >= 0 ) by Simpl // Auto
132
132
// @formatter:on
133
133
)
134
134
return
@@ -329,6 +329,75 @@ object List {
329
329
}
330
330
}
331
331
332
+ @ pure def lookupUpdateNeInduct [K , V ](map : Map [K , V ], key1 : K , key2 : K , value : V ): Unit = {
333
+ Contract (
334
+ Requires (key1 ≢ key2),
335
+ Ensures (lookup(update(map, key1, value), key2) ≡ lookup(map, key2))
336
+ )
337
+ (map : @ induct) match {
338
+ case Cons (p, next) => {
339
+
340
+ if (p._1 ≡ key1) {
341
+
342
+ Deduce (
343
+ // @formatter:off
344
+ 1 ( map ≡ Cons (p, next) ) by Premise , // auto-generated
345
+ 2 ( key1 ≢ key2 ) by Premise ,
346
+ 3 ( p._1 ≡ key1 ) by Premise ,
347
+ 4 ( p._1 ≢ key2 ) by Auto ,
348
+ 5 ( update(map, key1, value) ≡ Cons (key1 ~> value, next) ) by RSimpl (RS (update _)), // Auto,
349
+ 6 ( lookup(update(map, key1, value), key2) ≡ lookup(map, key2) ) by RSimpl (RS (lookup _)) // Auto
350
+ // @formatter:on
351
+ )
352
+ return
353
+
354
+ } else {
355
+
356
+ if (p._1 ≡ key2) {
357
+ Deduce (
358
+ // @formatter:off
359
+ 1 ( map ≡ Cons (p, next) ) by Premise , // Auto-generated
360
+ 2 ( lookup(update(next, key1, value), key2) ≡ lookup(next, key2) ) by Premise , // Auto-generated
361
+ 3 ( key1 ≢ key2 ) by Premise ,
362
+ 4 ( ! (p._1 ≡ key1) ) by Premise ,
363
+ 5 ( p._1 ≡ key2 ) by Premise ,
364
+ 6 ( update(map, key1, value) ≡ Cons (p, update(next, key1, value)) ) by RSimpl (RS (update _)),
365
+ 7 ( lookup(update(map, key1, value), key2) ≡ lookup(map, key2) ) by RSimpl (RS (lookup _))
366
+ // @formatter:on
367
+ )
368
+ } else {
369
+ Deduce (
370
+ // @formatter:off
371
+ 1 ( map ≡ Cons (p, next) ) by Premise , // Auto-generated
372
+ 2 ( lookup(update(next, key1, value), key2) ≡ lookup(next, key2) ) by Premise , // Auto-generated
373
+ 3 ( key1 ≢ key2 ) by Premise ,
374
+ 4 ( ! (p._1 ≡ key1) ) by Premise ,
375
+ 5 ( ! (p._1 ≡ key2) ) by Premise ,
376
+ 6 ( update(map, key1, value) ≡ Cons (p, update(next, key1, value)) ) by RSimpl (RS (update _)),
377
+ 7 ( lookup(update(map, key1, value), key2) ≡ lookup(map, key2) ) by RSimpl (RS (lookup _))
378
+ // @formatter:on
379
+ )
380
+ }
381
+ return
382
+
383
+ }
384
+
385
+ }
386
+ case Nil () => {
387
+ Deduce (
388
+ // @formatter:off
389
+ 1 ( map ≡ Nil [(K , V )]() ) by Premise , // Auto-generated
390
+ 2 ( key1 ≢ key2 ) by Premise ,
391
+ 3 ( update(map, key1, value) ≡ Cons (key1 ~> value, Nil [(K , V )]()) ) by RSimpl (RS (update _)), // Auto,
392
+ 4 ( lookup(update(map, key1, value), key2) ≡ lookup(map, key2) ) by RSimpl (RS (lookup _)) // Auto,
393
+ // @formatter:on
394
+ )
395
+ return
396
+
397
+ }
398
+ }
399
+ }
400
+
332
401
}
333
402
334
403
@ strictpure def make [T ](value : T ): List [T ] = Cons (value, Nil ())
@@ -541,12 +610,12 @@ object List {
541
610
)
542
611
)
543
612
544
- q.strategy match {
613
+ ( q.strategy: @ induct) match {
545
614
case Queue .Strategy .DropEarliest => {
546
615
if (q.length < q.capacity) {
547
616
Deduce (
548
617
// @formatter:off
549
- 1 ( q.strategy ≡ List .Queue .Strategy .DropEarliest ) by Premise ,
618
+ 1 ( q.strategy ≡ List .Queue .Strategy .DropEarliest ) by Premise , // Auto-generated
550
619
2 ( q.length < q.capacity ) by Premise ,
551
620
3 ( q.push(a).capacity ≡ q.capacity ) by Simpl ,
552
621
4 ( q.push(a).strategy ≡ q.strategy ) by Simpl
@@ -556,7 +625,7 @@ object List {
556
625
} else {
557
626
Deduce (
558
627
// @formatter:off
559
- 1 ( q.strategy ≡ List .Queue .Strategy .DropEarliest ) by Premise ,
628
+ 1 ( q.strategy ≡ List .Queue .Strategy .DropEarliest ) by Premise , // Auto-generated
560
629
2 ( ! (q.length < q.capacity) ) by Premise ,
561
630
3 ( q.push(a).capacity ≡ q.capacity ) by Simpl ,
562
631
4 ( q.push(a).strategy ≡ q.strategy ) by Simpl
@@ -569,7 +638,7 @@ object List {
569
638
if (q.length < q.capacity) {
570
639
Deduce (
571
640
// @formatter:off
572
- 1 ( q.strategy ≡ List .Queue .Strategy .DropLatest ) by Premise ,
641
+ 1 ( q.strategy ≡ List .Queue .Strategy .DropLatest ) by Premise , // Auto-generated
573
642
2 ( q.length < q.capacity ) by Premise ,
574
643
3 ( q.push(a).capacity ≡ q.capacity ) by Simpl ,
575
644
4 ( q.push(a).strategy ≡ q.strategy ) by Simpl
@@ -579,7 +648,7 @@ object List {
579
648
} else {
580
649
Deduce (
581
650
// @formatter:off
582
- 1 ( q.strategy ≡ List .Queue .Strategy .DropLatest ) by Premise ,
651
+ 1 ( q.strategy ≡ List .Queue .Strategy .DropLatest ) by Premise , // Auto-generated
583
652
2 ( ! (q.length < q.capacity) ) by Premise ,
584
653
3 ( q.push(a).capacity ≡ q.capacity ) by Simpl ,
585
654
4 ( q.push(a).strategy ≡ q.strategy ) by Simpl
@@ -592,7 +661,7 @@ object List {
592
661
if (q.length < q.capacity) {
593
662
Deduce (
594
663
// @formatter:off
595
- 1 ( q.strategy ≡ List .Queue .Strategy .Error ) by Premise ,
664
+ 1 ( q.strategy ≡ List .Queue .Strategy .Error ) by Premise , // Auto-generated
596
665
2 ( q.length < q.capacity ) by Premise ,
597
666
3 ( q.push(a).capacity ≡ q.capacity ) by Simpl ,
598
667
4 ( q.push(a).strategy ≡ q.strategy ) by Simpl
@@ -602,7 +671,7 @@ object List {
602
671
} else {
603
672
Deduce (
604
673
// @formatter:off
605
- 1 ( q.strategy ≡ List .Queue .Strategy .Error ) by Premise ,
674
+ 1 ( q.strategy ≡ List .Queue .Strategy .Error ) by Premise , // Auto-generated
606
675
2 ( ! (q.length < q.capacity) ) by Premise ,
607
676
3 ( q.push(a).capacity ≡ q.capacity ) by Simpl ,
608
677
4 ( q.push(a).strategy ≡ q.strategy ) by Simpl
@@ -614,7 +683,7 @@ object List {
614
683
case Queue .Strategy .Unbounded => {
615
684
Deduce (
616
685
// @formatter:off
617
- 1 ( q.strategy ≡ List .Queue .Strategy .Unbounded ) by Premise ,
686
+ 1 ( q.strategy ≡ List .Queue .Strategy .Unbounded ) by Premise , // Auto-generated
618
687
2 ( q.push(a).capacity ≡ q.capacity ) by Simpl ,
619
688
3 ( q.push(a).strategy ≡ q.strategy ) by Simpl
620
689
// @formatter:on
@@ -630,7 +699,7 @@ object List {
630
699
Ensures (q.push(a).buffer ≡ (q.buffer ++ List .make(a)))
631
700
)
632
701
633
- q.strategy match {
702
+ ( q.strategy: @ induct) match {
634
703
case Queue .Strategy .DropEarliest => {
635
704
Deduce (
636
705
// @formatter:off
@@ -683,7 +752,7 @@ object List {
683
752
684
753
framePush(q, a)
685
754
686
- q.strategy match {
755
+ ( q.strategy: @ induct) match {
687
756
case Queue .Strategy .DropEarliest => {
688
757
if (q.length < q.capacity) {
689
758
0 commit comments