-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontinuity2b.lagda
2386 lines (2004 loc) · 171 KB
/
continuity2b.lagda
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
\begin{code}
{-# OPTIONS --rewriting #-}
{-# OPTIONS --guardedness #-}
--{-# OPTIONS --auto-inline #-}
open import Level using (Level ; 0ℓ ; Lift ; lift ; lower) renaming (suc to lsuc)
open import Agda.Builtin.Bool
open import Agda.Builtin.Equality
open import Agda.Builtin.Equality.Rewrite
open import Agda.Builtin.Sigma
open import Relation.Nullary
open import Relation.Unary using (Pred; Decidable)
open import Relation.Binary.PropositionalEquality using (sym ; trans ; subst)
open import Data.Product
open import Data.Product.Properties
open import Data.Sum
open import Data.Empty
open import Data.Maybe
open import Data.Unit using (⊤ ; tt)
open import Data.Nat using (ℕ ; _<_ ; _≤_ ; _≥_ ; _≤?_ ; suc ; _+_ ; pred)
open import Data.Nat.Properties
open import Data.Bool using (Bool ; _∧_ ; _∨_)
open import Agda.Builtin.String
open import Agda.Builtin.String.Properties
open import Data.List
open import Data.List.Properties
open import Data.List.Relation.Unary.Any
open import Data.List.Relation.Binary.Subset.Propositional
open import Data.List.Relation.Binary.Subset.Propositional.Properties
open import Data.List.Membership.Propositional
open import Data.List.Membership.Propositional.Properties
open import Function.Bundles
open import Induction.WellFounded
open import util
open import name
open import calculus
open import terms
open import world
open import choice
open import choiceExt
open import choiceVal
open import compatible
open import getChoice
open import progress
open import freeze
open import newChoice
open import mod
open import choiceBar
open import encode
module continuity2b {L : Level} (W : PossibleWorlds {L}) (M : Mod W)
(C : Choice)
(K : Compatible {L} W C)
(G : GetChoice {L} W C K)
(X : ChoiceExt W C)
(N : NewChoice {L} W C K G)
(EC : Encode)
where
open import worldDef(W)
open import computation(W)(C)(K)(G)(X)(N)(EC)
open import terms2(W)(C)(K)(G)(X)(N)(EC)
open import terms3(W)(C)(K)(G)(X)(N)(EC)
open import terms4(W)(C)(K)(G)(X)(N)(EC)
open import terms5(W)(C)(K)(G)(X)(N)(EC)
open import terms6(W)(C)(K)(G)(X)(N)(EC)
open import bar(W)
open import barI(W)(M)--(C)(K)(P)
open import forcing(W)(M)(C)(K)(G)(X)(N)(EC)
open import props0(W)(M)(C)(K)(G)(X)(N)(EC)
open import ind2(W)(M)(C)(K)(G)(X)(N)(EC)
open import choiceDef{L}(C)
open import compatibleDef{L}(W)(C)(K)
open import getChoiceDef(W)(C)(K)(G)
open import newChoiceDef(W)(C)(K)(G)(N)
open import choiceExtDef(W)(C)(K)(G)(X)
open import encodeDef(EC)
open import props1(W)(M)(C)(K)(G)(X)(N)(EC)
open import props2(W)(M)(C)(K)(G)(X)(N)(EC)
open import props3(W)(M)(C)(K)(G)(X)(N)(EC)
open import props4(W)(M)(C)(K)(G)(X)(N)(EC)
open import continuity-conds(W)(C)(K)(G)(X)(N)(EC)
open import continuity1(W)(M)(C)(K)(G)(X)(N)(EC)
open import continuity2(W)(M)(C)(K)(G)(X)(N)(EC)
open import continuity3(W)(M)(C)(K)(G)(X)(N)(EC)
open import continuity1b(W)(M)(C)(K)(G)(X)(N)(EC)
data updCtxt2 (name : Name) (f : Term) : Term → Set where
updCtxt2-VAR : (x : Var) → updCtxt2 name f (VAR x)
-- updCtxt2-NAT : updCtxt2 name f NAT
updCtxt2-QNAT : updCtxt2 name f QNAT
-- updCtxt2-TNAT : updCtxt2 name f TNAT
updCtxt2-LT : (a b : Term) → updCtxt2 name f a → updCtxt2 name f b → updCtxt2 name f (LT a b)
updCtxt2-QLT : (a b : Term) → updCtxt2 name f a → updCtxt2 name f b → updCtxt2 name f (QLT a b)
updCtxt2-NUM : (x : ℕ) → updCtxt2 name f (NUM x)
updCtxt2-IFLT : (a b c d : Term) → updCtxt2 name f a → updCtxt2 name f b → updCtxt2 name f c → updCtxt2 name f d → updCtxt2 name f (IFLT a b c d)
updCtxt2-IFEQ : (a b c d : Term) → updCtxt2 name f a → updCtxt2 name f b → updCtxt2 name f c → updCtxt2 name f d → updCtxt2 name f (IFEQ a b c d)
updCtxt2-SUC : (a : Term) → updCtxt2 name f a → updCtxt2 name f (SUC a)
updCtxt2-NATREC : (a b c : Term) → updCtxt2 name f a → updCtxt2 name f b → updCtxt2 name f c → updCtxt2 name f (NATREC a b c)
updCtxt2-PI : (a b : Term) → updCtxt2 name f a → updCtxt2 name f b → updCtxt2 name f (PI a b)
updCtxt2-LAMBDA : (a : Term) → updCtxt2 name f a → updCtxt2 name f (LAMBDA a)
updCtxt2-MSEQ : (s : 𝕊) → updCtxt2 name f (MSEQ s)
updCtxt2-MAPP : (s : 𝕊) (a : Term) → updCtxt2 name f a → updCtxt2 name f (MAPP s a)
updCtxt2-APPLY : (a b : Term) → updCtxt2 name f a → updCtxt2 name f b → updCtxt2 name f (APPLY a b)
updCtxt2-FIX : (a : Term) → updCtxt2 name f a → updCtxt2 name f (FIX a)
updCtxt2-LET : (a b : Term) → updCtxt2 name f a → updCtxt2 name f b → updCtxt2 name f (LET a b)
updCtxt2-SUM : (a b : Term) → updCtxt2 name f a → updCtxt2 name f b → updCtxt2 name f (SUM a b)
updCtxt2-PAIR : (a b : Term) → updCtxt2 name f a → updCtxt2 name f b → updCtxt2 name f (PAIR a b)
updCtxt2-SPREAD : (a b : Term) → updCtxt2 name f a → updCtxt2 name f b → updCtxt2 name f (SPREAD a b)
updCtxt2-WT : (a b c : Term) → updCtxt2 name f a → updCtxt2 name f b → updCtxt2 name f c → updCtxt2 name f (WT a b c)
updCtxt2-SUP : (a b : Term) → updCtxt2 name f a → updCtxt2 name f b → updCtxt2 name f (SUP a b)
updCtxt2-WREC : (a b : Term) → updCtxt2 name f a → updCtxt2 name f b → updCtxt2 name f (WREC a b)
updCtxt2-MT : (a b c : Term) → updCtxt2 name f a → updCtxt2 name f b → updCtxt2 name f c → updCtxt2 name f (MT a b c)
updCtxt2-SET : (a b : Term) → updCtxt2 name f a → updCtxt2 name f b → updCtxt2 name f (SET a b)
updCtxt2-ISECT : (a b : Term) → updCtxt2 name f a → updCtxt2 name f b → updCtxt2 name f (ISECT a b)
updCtxt2-TUNION : (a b : Term) → updCtxt2 name f a → updCtxt2 name f b → updCtxt2 name f (TUNION a b)
updCtxt2-UNION : (a b : Term) → updCtxt2 name f a → updCtxt2 name f b → updCtxt2 name f (UNION a b)
-- updCtxt2-QTUNION : (a b : Term) → updCtxt2 name f a → updCtxt2 name f b → updCtxt2 name f (QTUNION a b)
updCtxt2-INL : (a : Term) → updCtxt2 name f a → updCtxt2 name f (INL a)
updCtxt2-INR : (a : Term) → updCtxt2 name f a → updCtxt2 name f (INR a)
updCtxt2-DECIDE : (a b c : Term) → updCtxt2 name f a → updCtxt2 name f b → updCtxt2 name f c → updCtxt2 name f (DECIDE a b c)
updCtxt2-EQ : (a b c : Term) → updCtxt2 name f a → updCtxt2 name f b → updCtxt2 name f c → updCtxt2 name f (EQ a b c)
-- updCtxt2-EQB : (a b c d : Term) → updCtxt2 name f a → updCtxt2 name f b → updCtxt2 name f c → updCtxt2 name f d → updCtxt2 name f (EQB a b c d)
updCtxt2-AX : updCtxt2 name f AX
updCtxt2-FREE : updCtxt2 name f FREE
updCtxt2-CS : (name' : Name) → updCtxt2 name f (CS name')
updCtxt2-NAME : (name' : Name) → ¬ name' ≡ name → updCtxt2 name f (NAME name')
updCtxt2-FRESH : (a : Term) → updCtxt2 (suc name) (shiftNameUp 0 f) a → updCtxt2 name f (FRESH a)
updCtxt2-LOAD : (a : Term) → updCtxt2 name f (LOAD a)
updCtxt2-CHOOSE : (a b : Term) → updCtxt2 name f a → updCtxt2 name f b → updCtxt2 name f (CHOOSE a b)
-- updCtxt2-IFC0 : (a₁ a₂ b₁ b₂ c₁ c₂ : Term) → updCtxt2 name1 name2 f a₁ a₂ → updCtxt2 name1 name2 f b₁ b₂ → updCtxt2 name1 name2 f c₁ c₂ → updCtxt2 name1 name2 f (IFC0 a₁ b₁ c₁) (IFC0 a₂ b₂ c₂)
-- updCtxt2-TSQUASH : (a : Term) → updCtxt2 name f a → updCtxt2 name f (TSQUASH a)
-- updCtxt2-TTRUNC : (a : Term) → updCtxt2 name f a → updCtxt2 name f (TTRUNC a)
updCtxt2-NOWRITE : updCtxt2 name f NOWRITE
updCtxt2-NOREAD : updCtxt2 name f NOREAD
updCtxt2-SUBSING : (a : Term) → updCtxt2 name f a → updCtxt2 name f (SUBSING a)
updCtxt2-PURE : updCtxt2 name f PURE
updCtxt2-NOSEQ : updCtxt2 name f NOSEQ
updCtxt2-NOENC : updCtxt2 name f NOENC
updCtxt2-TERM : (a : Term) → updCtxt2 name f a → updCtxt2 name f (TERM a)
updCtxt2-ENC : (a : Term) → updCtxt2 name f a → updCtxt2 name f (ENC a)
updCtxt2-PARTIAL : (a : Term) → updCtxt2 name f a → updCtxt2 name f (PARTIAL a)
updCtxt2-FFDEFS : (a b : Term) → updCtxt2 name f a → updCtxt2 name f b → updCtxt2 name f (FFDEFS a b)
updCtxt2-UNIV : (x : ℕ) → updCtxt2 name f (UNIV x)
updCtxt2-LIFT : (a : Term) → updCtxt2 name f a → updCtxt2 name f (LIFT a)
updCtxt2-LOWER : (a : Term) → updCtxt2 name f a → updCtxt2 name f (LOWER a)
updCtxt2-SHRINK : (a : Term) → updCtxt2 name f a → updCtxt2 name f (SHRINK a)
updCtxt2-upd : updCtxt2 name f (upd name f)
∈names𝕎 : {k : ℕ} {w1 w2 : 𝕎·} {a b : Term} (name : Name)
→ steps k (a , w1) ≡ (b , w2)
→ Set
∈names𝕎 {0} {w1} {w2} {a} {b} name comp = ¬ name ∈ names𝕎· w1 × name ∈ dom𝕎· w1
∈names𝕎 {suc k} {w1} {w2} {a} {b} name comp with step a w1
... | just (x , w) = ¬ name ∈ names𝕎· w1 × name ∈ dom𝕎· w1 × ∈names𝕎 {k} {w} {w2} {x} {b} name comp
... | nothing = ¬ name ∈ names𝕎· w1 × name ∈ dom𝕎· w1
pres∈names𝕎 : {k : ℕ} {w1 w2 : 𝕎·} {a b : Term} (name : Name) (comp : steps k (a , w1) ≡ (b , w2)) → Set
pres∈names𝕎 {k} {w1} {w2} {a} {b} name comp =
¬ name ∈ names𝕎· w1
→ name ∈ dom𝕎· w1
→ ∈names𝕎 {k} {w1} {w2} {a} {b} name comp
∈names𝕎→¬∈name𝕎 : {k : ℕ} {w1 w2 : 𝕎·} {a b : Term} (name : Name)
(comp : steps k (a , w1) ≡ (b , w2))
→ ∈names𝕎 {k} {w1} {w2} {a} {b} name comp
→ ¬ name ∈ names𝕎· w1
∈names𝕎→¬∈name𝕎 {0} {w1} {w2} {a} {b} name comp inw = fst inw
∈names𝕎→¬∈name𝕎 {suc k} {w1} {w2} {a} {b} name comp inw with step⊎ a w1
... | inj₁ (a' , w1' , z) rewrite z = fst inw
... | inj₂ z rewrite z = fst inw
∈names𝕎→∈dom𝕎 : {k : ℕ} {w1 w2 : 𝕎·} {a b : Term} (name : Name)
(comp : steps k (a , w1) ≡ (b , w2))
→ ∈names𝕎 {k} {w1} {w2} {a} {b} name comp
→ name ∈ dom𝕎· w1
∈names𝕎→∈dom𝕎 {0} {w1} {w2} {a} {b} name comp inw = snd inw
∈names𝕎→∈dom𝕎 {suc k} {w1} {w2} {a} {b} name comp inw with step⊎ a w1
... | inj₁ (a' , w1' , z) rewrite z = fst (snd inw)
... | inj₂ z rewrite z = snd inw
presHighestℕ2 : (name : Name) (f : Term) (k : ℕ) → Set(lsuc L)
presHighestℕ2 name f k =
{w1 w2 : 𝕎·} {a b : Term} {n : ℕ}
(comp : steps k (a , w1) ≡ (b , w2))
→ isValue b
→ updCtxt2 name f a
→ compatible· name w1 Res⊤
→ ∀𝕎-get0-NUM w1 name
→ ¬ name ∈ names𝕎· w1
→ name ∈ dom𝕎· w1
→ (getT≤ℕ w2 n name --getT 0 name w2 ≡ just (NUM n)
→ isHighestℕ {k} {w1} {w2} {a} {b} n name comp)
× ∈names𝕎 {k} {w1} {w2} {a} {b} name comp
stepsPresHighestℕ2 : (name : Name) (f : Term) (b : Term) (w : 𝕎·) → Set(lsuc L)
stepsPresHighestℕ2 name f b w =
Σ ℕ (λ k → Σ Term (λ v → Σ 𝕎· (λ w' →
steps k (b , w) ≡ (v , w')
× isValue v
× ((k' : ℕ) → k' ≤ k → presHighestℕ2 name f k'))))
ΣhighestUpdCtxtAux2 : (k' : ℕ) (name : Name) (f : Term) (n : ℕ) (a a' : Term) (w0 w w' : 𝕎·) → Set(L)
ΣhighestUpdCtxtAux2 k' name f n a a' w0 w w' =
Σ (steps k' (a , w) ≡ (a' , w')) (λ comp →
(getT≤ℕ w' n name → (getT≤ℕ w0 n name × isHighestℕ {k'} {w} {w'} {a} {a'} n name comp))
× ∈names𝕎 {k'} {w} {w'} {a} {a'} name comp
× updCtxt2 name f a')
ΣhighestUpdCtxt2 : (name : Name) (f : Term) (n : ℕ) (a : Term) (w0 w : 𝕎·) → Set(L)
ΣhighestUpdCtxt2 name f n a w0 w =
Σ ℕ (λ k' → Σ Term (λ a' → Σ 𝕎· (λ w' →
ΣhighestUpdCtxtAux2 k' name f n a a' w0 w w')))
abstract
→updCtxt2-shiftUp : (v : Var) {name : Name} {f : Term} (cf : # f) {a : Term}
→ updCtxt2 name f a
→ updCtxt2 name f (shiftUp v a)
→updCtxt2-shiftUp v {name} {f} cf {.(VAR x)} (updCtxt2-VAR x) = updCtxt2-VAR _
-- →updCtxt2-shiftUp v {name} {f} cf {.NAT} updCtxt2-NAT = updCtxt2-NAT
→updCtxt2-shiftUp v {name} {f} cf {.QNAT} updCtxt2-QNAT = updCtxt2-QNAT
-- →updCtxt2-shiftUp v {name} {f} cf {.TNAT} updCtxt2-TNAT = updCtxt2-TNAT
→updCtxt2-shiftUp v {name} {f} cf {.(LT a b)} (updCtxt2-LT a b upd₁ upd₂) = updCtxt2-LT _ _ (→updCtxt2-shiftUp v cf upd₁) (→updCtxt2-shiftUp v cf upd₂)
→updCtxt2-shiftUp v {name} {f} cf {.(QLT a b)} (updCtxt2-QLT a b upd₁ upd₂) = updCtxt2-QLT _ _ (→updCtxt2-shiftUp v cf upd₁) (→updCtxt2-shiftUp v cf upd₂)
→updCtxt2-shiftUp v {name} {f} cf {.(NUM x)} (updCtxt2-NUM x) = updCtxt2-NUM _
→updCtxt2-shiftUp v {name} {f} cf {.(IFLT a b c d)} (updCtxt2-IFLT a b c d upd₁ upd₂ upd₃ upd₄) = updCtxt2-IFLT _ _ _ _ (→updCtxt2-shiftUp v cf upd₁) (→updCtxt2-shiftUp v cf upd₂) (→updCtxt2-shiftUp v cf upd₃) (→updCtxt2-shiftUp v cf upd₄)
→updCtxt2-shiftUp v {name} {f} cf {.(IFEQ a b c d)} (updCtxt2-IFEQ a b c d upd₁ upd₂ upd₃ upd₄) = updCtxt2-IFEQ _ _ _ _ (→updCtxt2-shiftUp v cf upd₁) (→updCtxt2-shiftUp v cf upd₂) (→updCtxt2-shiftUp v cf upd₃) (→updCtxt2-shiftUp v cf upd₄)
→updCtxt2-shiftUp v {name} {f} cf {.(SUC a)} (updCtxt2-SUC a upd₁) = updCtxt2-SUC _ (→updCtxt2-shiftUp v cf upd₁)
→updCtxt2-shiftUp v {name} {f} cf {.(NATREC a b c)} (updCtxt2-NATREC a b c upd₁ upd₂ upd₃) = updCtxt2-NATREC _ _ _ (→updCtxt2-shiftUp v cf upd₁) (→updCtxt2-shiftUp v cf upd₂) (→updCtxt2-shiftUp v cf upd₃)
→updCtxt2-shiftUp v {name} {f} cf {.(PI a b)} (updCtxt2-PI a b upd₁ upd₂) = updCtxt2-PI _ _ (→updCtxt2-shiftUp v cf upd₁) (→updCtxt2-shiftUp (suc v) cf upd₂)
→updCtxt2-shiftUp v {name} {f} cf {.(LAMBDA a)} (updCtxt2-LAMBDA a upd₁) = updCtxt2-LAMBDA _ (→updCtxt2-shiftUp (suc v) cf upd₁)
→updCtxt2-shiftUp v {name} {f} cf {.(MSEQ s)} (updCtxt2-MSEQ s) = updCtxt2-MSEQ _
→updCtxt2-shiftUp v {name} {f} cf {.(MAPP s a)} (updCtxt2-MAPP s a upd₁) = updCtxt2-MAPP _ _ (→updCtxt2-shiftUp v cf upd₁)
→updCtxt2-shiftUp v {name} {f} cf {.(APPLY a b)} (updCtxt2-APPLY a b upd₁ upd₂) = updCtxt2-APPLY _ _ (→updCtxt2-shiftUp v cf upd₁) (→updCtxt2-shiftUp v cf upd₂)
→updCtxt2-shiftUp v {name} {f} cf {.(FIX a)} (updCtxt2-FIX a upd₁) = updCtxt2-FIX _ (→updCtxt2-shiftUp v cf upd₁)
→updCtxt2-shiftUp v {name} {f} cf {.(LET a b)} (updCtxt2-LET a b upd₁ upd₂) = updCtxt2-LET _ _ (→updCtxt2-shiftUp v cf upd₁) (→updCtxt2-shiftUp (suc v) cf upd₂)
→updCtxt2-shiftUp v {name} {f} cf {.(SUM a b)} (updCtxt2-SUM a b upd₁ upd₂) = updCtxt2-SUM _ _ (→updCtxt2-shiftUp v cf upd₁) (→updCtxt2-shiftUp (suc v) cf upd₂)
→updCtxt2-shiftUp v {name} {f} cf {.(PAIR a b)} (updCtxt2-PAIR a b upd₁ upd₂) = updCtxt2-PAIR _ _ (→updCtxt2-shiftUp v cf upd₁) (→updCtxt2-shiftUp v cf upd₂)
→updCtxt2-shiftUp v {name} {f} cf {.(SPREAD a b)} (updCtxt2-SPREAD a b upd₁ upd₂) = updCtxt2-SPREAD _ _ (→updCtxt2-shiftUp v cf upd₁) (→updCtxt2-shiftUp (suc (suc v)) cf upd₂)
→updCtxt2-shiftUp v {name} {f} cf {.(WT a b c)} (updCtxt2-WT a b c upd₁ upd₂ upd₃) = updCtxt2-WT _ _ _ (→updCtxt2-shiftUp v cf upd₁) (→updCtxt2-shiftUp (suc v) cf upd₂) (→updCtxt2-shiftUp v cf upd₃)
→updCtxt2-shiftUp v {name} {f} cf {.(SUP a b)} (updCtxt2-SUP a b upd₁ upd₂) = updCtxt2-SUP _ _ (→updCtxt2-shiftUp v cf upd₁) (→updCtxt2-shiftUp v cf upd₂)
→updCtxt2-shiftUp v {name} {f} cf {.(WREC a b)} (updCtxt2-WREC a b upd₁ upd₂) = updCtxt2-WREC _ _ (→updCtxt2-shiftUp v cf upd₁) (→updCtxt2-shiftUp (suc (suc (suc v))) cf upd₂)
→updCtxt2-shiftUp v {name} {f} cf {.(MT a b c)} (updCtxt2-MT a b c upd₁ upd₂ upd₃) = updCtxt2-MT _ _ _ (→updCtxt2-shiftUp v cf upd₁) (→updCtxt2-shiftUp (suc v) cf upd₂) (→updCtxt2-shiftUp v cf upd₃)
→updCtxt2-shiftUp v {name} {f} cf {.(SET a b)} (updCtxt2-SET a b upd₁ upd₂) = updCtxt2-SET _ _ (→updCtxt2-shiftUp v cf upd₁) (→updCtxt2-shiftUp (suc v) cf upd₂)
→updCtxt2-shiftUp v {name} {f} cf {.(ISECT a b)} (updCtxt2-ISECT a b upd₁ upd₂) = updCtxt2-ISECT _ _ (→updCtxt2-shiftUp v cf upd₁) (→updCtxt2-shiftUp v cf upd₂)
→updCtxt2-shiftUp v {name} {f} cf {.(TUNION a b)} (updCtxt2-TUNION a b upd₁ upd₂) = updCtxt2-TUNION _ _ (→updCtxt2-shiftUp v cf upd₁) (→updCtxt2-shiftUp (suc v) cf upd₂)
→updCtxt2-shiftUp v {name} {f} cf {.(UNION a b)} (updCtxt2-UNION a b upd₁ upd₂) = updCtxt2-UNION _ _ (→updCtxt2-shiftUp v cf upd₁) (→updCtxt2-shiftUp v cf upd₂)
-- →updCtxt2-shiftUp v {name} {f} cf {.(QTUNION a b)} (updCtxt2-QTUNION a b upd₁ upd₂) = updCtxt2-QTUNION _ _ (→updCtxt2-shiftUp v cf upd₁) (→updCtxt2-shiftUp v cf upd₂)
→updCtxt2-shiftUp v {name} {f} cf {.(INL a)} (updCtxt2-INL a upd₁) = updCtxt2-INL _ (→updCtxt2-shiftUp v cf upd₁)
→updCtxt2-shiftUp v {name} {f} cf {.(INR a)} (updCtxt2-INR a upd₁) = updCtxt2-INR _ (→updCtxt2-shiftUp v cf upd₁)
→updCtxt2-shiftUp v {name} {f} cf {.(DECIDE a b c)} (updCtxt2-DECIDE a b c upd₁ upd₂ upd₃) = updCtxt2-DECIDE _ _ _ (→updCtxt2-shiftUp v cf upd₁) (→updCtxt2-shiftUp (suc v) cf upd₂) (→updCtxt2-shiftUp (suc v) cf upd₃)
→updCtxt2-shiftUp v {name} {f} cf {.(EQ a b c)} (updCtxt2-EQ a b c upd₁ upd₂ upd₃) = updCtxt2-EQ _ _ _ (→updCtxt2-shiftUp v cf upd₁) (→updCtxt2-shiftUp v cf upd₂) (→updCtxt2-shiftUp v cf upd₃)
-- →updCtxt2-shiftUp v {name} {f} cf {.(EQB a b c d)} (updCtxt2-EQB a b c d upd₁ upd₂ upd₃ upd₄) = updCtxt2-EQB _ _ _ _ (→updCtxt2-shiftUp v cf upd₁) (→updCtxt2-shiftUp v cf upd₂) (→updCtxt2-shiftUp v cf upd₃) (→updCtxt2-shiftUp v cf upd₄)
→updCtxt2-shiftUp v {name} {f} cf {.AX} updCtxt2-AX = updCtxt2-AX
→updCtxt2-shiftUp v {name} {f} cf {.FREE} updCtxt2-FREE = updCtxt2-FREE
→updCtxt2-shiftUp v {name} {f} cf {.(CS name')} (updCtxt2-CS name') = updCtxt2-CS _
→updCtxt2-shiftUp v {name} {f} cf {.(NAME name')} (updCtxt2-NAME name' x) = updCtxt2-NAME _ x
→updCtxt2-shiftUp v {name} {f} cf {.(FRESH a)} (updCtxt2-FRESH a upd₁) = updCtxt2-FRESH _ (→updCtxt2-shiftUp v (→#shiftNameUp 0 {f} cf) upd₁)
→updCtxt2-shiftUp v {name} {f} cf {.(LOAD a)} (updCtxt2-LOAD a) = updCtxt2-LOAD _ --upd₁ --updCtxt2-LOAD _ (→updCtxt2-shiftUp v cf upd₁)
→updCtxt2-shiftUp v {name} {f} cf {.(CHOOSE a b)} (updCtxt2-CHOOSE a b upd₁ upd₂) = updCtxt2-CHOOSE _ _ (→updCtxt2-shiftUp v cf upd₁) (→updCtxt2-shiftUp v cf upd₂)
-- →updCtxt2-shiftUp v {name} {f} cf {.(TSQUASH a)} (updCtxt2-TSQUASH a upd₁) = updCtxt2-TSQUASH _ (→updCtxt2-shiftUp v cf upd₁)
-- →updCtxt2-shiftUp v {name} {f} cf {.(TTRUNC a)} (updCtxt2-TTRUNC a upd₁) = updCtxt2-TTRUNC _ (→updCtxt2-shiftUp v cf upd₁)
→updCtxt2-shiftUp v {name} {f} cf {.NOWRITE} updCtxt2-NOWRITE = updCtxt2-NOWRITE
→updCtxt2-shiftUp v {name} {f} cf {.NOREAD} updCtxt2-NOREAD = updCtxt2-NOREAD
→updCtxt2-shiftUp v {name} {f} cf {.(SUBSING a)} (updCtxt2-SUBSING a upd₁) = updCtxt2-SUBSING _ (→updCtxt2-shiftUp v cf upd₁)
→updCtxt2-shiftUp v {name} {f} cf {.PURE} updCtxt2-PURE = updCtxt2-PURE
→updCtxt2-shiftUp v {name} {f} cf {.NOSEQ} updCtxt2-NOSEQ = updCtxt2-NOSEQ
→updCtxt2-shiftUp v {name} {f} cf {.NOENC} updCtxt2-NOENC = updCtxt2-NOENC
→updCtxt2-shiftUp v {name} {f} cf {.(TERM a)} (updCtxt2-TERM a upd₁) = updCtxt2-TERM _ (→updCtxt2-shiftUp v cf upd₁)
→updCtxt2-shiftUp v {name} {f} cf {.(ENC a)} (updCtxt2-ENC a upd₁) = updCtxt2-ENC _ upd₁
→updCtxt2-shiftUp v {name} {f} cf {.(PARTIAL a)} (updCtxt2-PARTIAL a upd₁) = updCtxt2-PARTIAL _ (→updCtxt2-shiftUp v cf upd₁)
→updCtxt2-shiftUp v {name} {f} cf {.(FFDEFS a b)} (updCtxt2-FFDEFS a b upd₁ upd₂) = updCtxt2-FFDEFS _ _ (→updCtxt2-shiftUp v cf upd₁) (→updCtxt2-shiftUp v cf upd₂)
→updCtxt2-shiftUp v {name} {f} cf {.(UNIV x)} (updCtxt2-UNIV x) = updCtxt2-UNIV _
→updCtxt2-shiftUp v {name} {f} cf {.(LIFT a)} (updCtxt2-LIFT a upd₁) = updCtxt2-LIFT _ (→updCtxt2-shiftUp v cf upd₁)
→updCtxt2-shiftUp v {name} {f} cf {.(LOWER a)} (updCtxt2-LOWER a upd₁) = updCtxt2-LOWER _ (→updCtxt2-shiftUp v cf upd₁)
→updCtxt2-shiftUp v {name} {f} cf {.(SHRINK a)} (updCtxt2-SHRINK a upd₁) = updCtxt2-SHRINK _ (→updCtxt2-shiftUp v cf upd₁)
→updCtxt2-shiftUp v {name} {f} cf {.(upd name f)} updCtxt2-upd
rewrite sucIf≤s0 v | #shiftUp (suc (suc (suc v))) (ct (shiftUp 0 f) (→#shiftUp 0 {f} cf)) = updCtxt2-upd
abstract
→updCtxt2-shiftDown : (v : Var) {name : Name} {f : Term} (cf : # f) {a : Term}
→ updCtxt2 name f a
→ updCtxt2 name f (shiftDown v a)
→updCtxt2-shiftDown v {name} {f} cf {.(VAR x)} (updCtxt2-VAR x) = updCtxt2-VAR _
-- →updCtxt2-shiftDown v {name} {f} cf {.NAT} updCtxt2-NAT = updCtxt2-NAT
→updCtxt2-shiftDown v {name} {f} cf {.QNAT} updCtxt2-QNAT = updCtxt2-QNAT
-- →updCtxt2-shiftDown v {name} {f} cf {.TNAT} updCtxt2-TNAT = updCtxt2-TNAT
→updCtxt2-shiftDown v {name} {f} cf {.(LT a b)} (updCtxt2-LT a b upd₁ upd₂) = updCtxt2-LT _ _ (→updCtxt2-shiftDown v cf upd₁) (→updCtxt2-shiftDown v cf upd₂)
→updCtxt2-shiftDown v {name} {f} cf {.(QLT a b)} (updCtxt2-QLT a b upd₁ upd₂) = updCtxt2-QLT _ _ (→updCtxt2-shiftDown v cf upd₁) (→updCtxt2-shiftDown v cf upd₂)
→updCtxt2-shiftDown v {name} {f} cf {.(NUM x)} (updCtxt2-NUM x) = updCtxt2-NUM _
→updCtxt2-shiftDown v {name} {f} cf {.(IFLT a b c d)} (updCtxt2-IFLT a b c d upd₁ upd₂ upd₃ upd₄) = updCtxt2-IFLT _ _ _ _ (→updCtxt2-shiftDown v cf upd₁) (→updCtxt2-shiftDown v cf upd₂) (→updCtxt2-shiftDown v cf upd₃) (→updCtxt2-shiftDown v cf upd₄)
→updCtxt2-shiftDown v {name} {f} cf {.(IFEQ a b c d)} (updCtxt2-IFEQ a b c d upd₁ upd₂ upd₃ upd₄) = updCtxt2-IFEQ _ _ _ _ (→updCtxt2-shiftDown v cf upd₁) (→updCtxt2-shiftDown v cf upd₂) (→updCtxt2-shiftDown v cf upd₃) (→updCtxt2-shiftDown v cf upd₄)
→updCtxt2-shiftDown v {name} {f} cf {.(SUC a)} (updCtxt2-SUC a upd₁) = updCtxt2-SUC _ (→updCtxt2-shiftDown v cf upd₁)
→updCtxt2-shiftDown v {name} {f} cf {.(NATREC a b c)} (updCtxt2-NATREC a b c upd₁ upd₂ upd₃) = updCtxt2-NATREC _ _ _ (→updCtxt2-shiftDown v cf upd₁) (→updCtxt2-shiftDown v cf upd₂) (→updCtxt2-shiftDown v cf upd₃)
→updCtxt2-shiftDown v {name} {f} cf {.(PI a b)} (updCtxt2-PI a b upd₁ upd₂) = updCtxt2-PI _ _ (→updCtxt2-shiftDown v cf upd₁) (→updCtxt2-shiftDown (suc v) cf upd₂)
→updCtxt2-shiftDown v {name} {f} cf {.(LAMBDA a)} (updCtxt2-LAMBDA a upd₁) = updCtxt2-LAMBDA _ (→updCtxt2-shiftDown (suc v) cf upd₁)
→updCtxt2-shiftDown v {name} {f} cf {.(MSEQ s)} (updCtxt2-MSEQ s) = updCtxt2-MSEQ _
→updCtxt2-shiftDown v {name} {f} cf {.(MAPP s a)} (updCtxt2-MAPP s a upd₁) = updCtxt2-MAPP _ _ (→updCtxt2-shiftDown v cf upd₁)
→updCtxt2-shiftDown v {name} {f} cf {.(APPLY a b)} (updCtxt2-APPLY a b upd₁ upd₂) = updCtxt2-APPLY _ _ (→updCtxt2-shiftDown v cf upd₁) (→updCtxt2-shiftDown v cf upd₂)
→updCtxt2-shiftDown v {name} {f} cf {.(FIX a)} (updCtxt2-FIX a upd₁) = updCtxt2-FIX _ (→updCtxt2-shiftDown v cf upd₁)
→updCtxt2-shiftDown v {name} {f} cf {.(LET a b)} (updCtxt2-LET a b upd₁ upd₂) = updCtxt2-LET _ _ (→updCtxt2-shiftDown v cf upd₁) (→updCtxt2-shiftDown (suc v) cf upd₂)
→updCtxt2-shiftDown v {name} {f} cf {.(SUM a b)} (updCtxt2-SUM a b upd₁ upd₂) = updCtxt2-SUM _ _ (→updCtxt2-shiftDown v cf upd₁) (→updCtxt2-shiftDown (suc v) cf upd₂)
→updCtxt2-shiftDown v {name} {f} cf {.(PAIR a b)} (updCtxt2-PAIR a b upd₁ upd₂) = updCtxt2-PAIR _ _ (→updCtxt2-shiftDown v cf upd₁) (→updCtxt2-shiftDown v cf upd₂)
→updCtxt2-shiftDown v {name} {f} cf {.(SPREAD a b)} (updCtxt2-SPREAD a b upd₁ upd₂) = updCtxt2-SPREAD _ _ (→updCtxt2-shiftDown v cf upd₁) (→updCtxt2-shiftDown (suc (suc v)) cf upd₂)
→updCtxt2-shiftDown v {name} {f} cf {.(WT a b c)} (updCtxt2-WT a b c upd₁ upd₂ upd₃) = updCtxt2-WT _ _ _ (→updCtxt2-shiftDown v cf upd₁) (→updCtxt2-shiftDown (suc v) cf upd₂) (→updCtxt2-shiftDown v cf upd₃)
→updCtxt2-shiftDown v {name} {f} cf {.(SUP a b)} (updCtxt2-SUP a b upd₁ upd₂) = updCtxt2-SUP _ _ (→updCtxt2-shiftDown v cf upd₁) (→updCtxt2-shiftDown v cf upd₂)
→updCtxt2-shiftDown v {name} {f} cf {.(WREC a b)} (updCtxt2-WREC a b upd₁ upd₂) = updCtxt2-WREC _ _ (→updCtxt2-shiftDown v cf upd₁) (→updCtxt2-shiftDown (suc (suc (suc v))) cf upd₂)
→updCtxt2-shiftDown v {name} {f} cf {.(MT a b c)} (updCtxt2-MT a b c upd₁ upd₂ upd₃) = updCtxt2-MT _ _ _ (→updCtxt2-shiftDown v cf upd₁) (→updCtxt2-shiftDown (suc v) cf upd₂) (→updCtxt2-shiftDown v cf upd₃)
→updCtxt2-shiftDown v {name} {f} cf {.(SET a b)} (updCtxt2-SET a b upd₁ upd₂) = updCtxt2-SET _ _ (→updCtxt2-shiftDown v cf upd₁) (→updCtxt2-shiftDown (suc v) cf upd₂)
→updCtxt2-shiftDown v {name} {f} cf {.(ISECT a b)} (updCtxt2-ISECT a b upd₁ upd₂) = updCtxt2-ISECT _ _ (→updCtxt2-shiftDown v cf upd₁) (→updCtxt2-shiftDown v cf upd₂)
→updCtxt2-shiftDown v {name} {f} cf {.(TUNION a b)} (updCtxt2-TUNION a b upd₁ upd₂) = updCtxt2-TUNION _ _ (→updCtxt2-shiftDown v cf upd₁) (→updCtxt2-shiftDown (suc v) cf upd₂)
→updCtxt2-shiftDown v {name} {f} cf {.(UNION a b)} (updCtxt2-UNION a b upd₁ upd₂) = updCtxt2-UNION _ _ (→updCtxt2-shiftDown v cf upd₁) (→updCtxt2-shiftDown v cf upd₂)
-- →updCtxt2-shiftDown v {name} {f} cf {.(QTUNION a b)} (updCtxt2-QTUNION a b upd₁ upd₂) = updCtxt2-QTUNION _ _ (→updCtxt2-shiftDown v cf upd₁) (→updCtxt2-shiftDown v cf upd₂)
→updCtxt2-shiftDown v {name} {f} cf {.(INL a)} (updCtxt2-INL a upd₁) = updCtxt2-INL _ (→updCtxt2-shiftDown v cf upd₁)
→updCtxt2-shiftDown v {name} {f} cf {.(INR a)} (updCtxt2-INR a upd₁) = updCtxt2-INR _ (→updCtxt2-shiftDown v cf upd₁)
→updCtxt2-shiftDown v {name} {f} cf {.(DECIDE a b c)} (updCtxt2-DECIDE a b c upd₁ upd₂ upd₃) = updCtxt2-DECIDE _ _ _ (→updCtxt2-shiftDown v cf upd₁) (→updCtxt2-shiftDown (suc v) cf upd₂) (→updCtxt2-shiftDown (suc v) cf upd₃)
→updCtxt2-shiftDown v {name} {f} cf {.(EQ a b c)} (updCtxt2-EQ a b c upd₁ upd₂ upd₃) = updCtxt2-EQ _ _ _ (→updCtxt2-shiftDown v cf upd₁) (→updCtxt2-shiftDown v cf upd₂) (→updCtxt2-shiftDown v cf upd₃)
-- →updCtxt2-shiftDown v {name} {f} cf {.(EQB a b c d)} (updCtxt2-EQB a b c d upd₁ upd₂ upd₃ upd₄) = updCtxt2-EQB _ _ _ _ (→updCtxt2-shiftDown v cf upd₁) (→updCtxt2-shiftDown v cf upd₂) (→updCtxt2-shiftDown v cf upd₃) (→updCtxt2-shiftDown v cf upd₄)
→updCtxt2-shiftDown v {name} {f} cf {.AX} updCtxt2-AX = updCtxt2-AX
→updCtxt2-shiftDown v {name} {f} cf {.FREE} updCtxt2-FREE = updCtxt2-FREE
→updCtxt2-shiftDown v {name} {f} cf {.(CS name')} (updCtxt2-CS name') = updCtxt2-CS _
→updCtxt2-shiftDown v {name} {f} cf {.(NAME name')} (updCtxt2-NAME name' x) = updCtxt2-NAME _ x
→updCtxt2-shiftDown v {name} {f} cf {.(FRESH a)} (updCtxt2-FRESH a upd₁) = updCtxt2-FRESH _ (→updCtxt2-shiftDown v (→#shiftNameUp 0 {f} cf) upd₁)
→updCtxt2-shiftDown v {name} {f} cf {.(LOAD a)} (updCtxt2-LOAD a) = updCtxt2-LOAD _ --upd₁ --updCtxt2-LOAD _ (→updCtxt2-shiftDown v cf upd₁)
→updCtxt2-shiftDown v {name} {f} cf {.(CHOOSE a b)} (updCtxt2-CHOOSE a b upd₁ upd₂) = updCtxt2-CHOOSE _ _ (→updCtxt2-shiftDown v cf upd₁) (→updCtxt2-shiftDown v cf upd₂)
-- →updCtxt2-shiftDown v {name} {f} cf {.(TSQUASH a)} (updCtxt2-TSQUASH a upd₁) = updCtxt2-TSQUASH _ (→updCtxt2-shiftDown v cf upd₁)
-- →updCtxt2-shiftDown v {name} {f} cf {.(TTRUNC a)} (updCtxt2-TTRUNC a upd₁) = updCtxt2-TTRUNC _ (→updCtxt2-shiftDown v cf upd₁)
→updCtxt2-shiftDown v {name} {f} cf {.NOWRITE} updCtxt2-NOWRITE = updCtxt2-NOWRITE
→updCtxt2-shiftDown v {name} {f} cf {.NOREAD} updCtxt2-NOREAD = updCtxt2-NOREAD
→updCtxt2-shiftDown v {name} {f} cf {.(SUBSING a)} (updCtxt2-SUBSING a upd₁) = updCtxt2-SUBSING _ (→updCtxt2-shiftDown v cf upd₁)
→updCtxt2-shiftDown v {name} {f} cf {.PURE} updCtxt2-PURE = updCtxt2-PURE
→updCtxt2-shiftDown v {name} {f} cf {.NOSEQ} updCtxt2-NOSEQ = updCtxt2-NOSEQ
→updCtxt2-shiftDown v {name} {f} cf {.NOENC} updCtxt2-NOENC = updCtxt2-NOENC
→updCtxt2-shiftDown v {name} {f} cf {.(TERM a)} (updCtxt2-TERM a upd₁) = updCtxt2-TERM _ (→updCtxt2-shiftDown v cf upd₁)
→updCtxt2-shiftDown v {name} {f} cf {.(ENC a)} (updCtxt2-ENC a upd₁) = updCtxt2-ENC _ upd₁
→updCtxt2-shiftDown v {name} {f} cf {.(PARTIAL a)} (updCtxt2-PARTIAL a upd₁) = updCtxt2-PARTIAL _ (→updCtxt2-shiftDown v cf upd₁)
→updCtxt2-shiftDown v {name} {f} cf {.(FFDEFS a b)} (updCtxt2-FFDEFS a b upd₁ upd₂) = updCtxt2-FFDEFS _ _ (→updCtxt2-shiftDown v cf upd₁) (→updCtxt2-shiftDown v cf upd₂)
→updCtxt2-shiftDown v {name} {f} cf {.(UNIV x)} (updCtxt2-UNIV x) = updCtxt2-UNIV _
→updCtxt2-shiftDown v {name} {f} cf {.(LIFT a)} (updCtxt2-LIFT a upd₁) = updCtxt2-LIFT _ (→updCtxt2-shiftDown v cf upd₁)
→updCtxt2-shiftDown v {name} {f} cf {.(LOWER a)} (updCtxt2-LOWER a upd₁) = updCtxt2-LOWER _ (→updCtxt2-shiftDown v cf upd₁)
→updCtxt2-shiftDown v {name} {f} cf {.(SHRINK a)} (updCtxt2-SHRINK a upd₁) = updCtxt2-SHRINK _ (→updCtxt2-shiftDown v cf upd₁)
→updCtxt2-shiftDown v {name} {f} cf {.(upd name f)} updCtxt2-upd
rewrite sucIf≤s0 v | #shiftDown (suc (suc (suc v))) (ct (shiftUp 0 f) (→#shiftUp 0 {f} cf)) = updCtxt2-upd
abstract
→updCtxt2-shiftNameUp : (v : Var) {name : Name} {f : Term} (cf : # f) {a : Term}
→ updCtxt2 name f a
→ updCtxt2 (sucIf≤ v name) (shiftNameUp v f) (shiftNameUp v a)
→updCtxt2-shiftNameUp v {name} {f} cf {.(VAR x)} (updCtxt2-VAR x) = updCtxt2-VAR _
-- →updCtxt2-shiftNameUp v {name} {f} cf {.NAT} updCtxt2-NAT = updCtxt2-NAT
→updCtxt2-shiftNameUp v {name} {f} cf {.QNAT} updCtxt2-QNAT = updCtxt2-QNAT
-- →updCtxt2-shiftNameUp v {name} {f} cf {.TNAT} updCtxt2-TNAT = updCtxt2-TNAT
→updCtxt2-shiftNameUp v {name} {f} cf {.(LT a b)} (updCtxt2-LT a b upd₁ upd₂) = updCtxt2-LT _ _ (→updCtxt2-shiftNameUp v cf upd₁) (→updCtxt2-shiftNameUp v cf upd₂)
→updCtxt2-shiftNameUp v {name} {f} cf {.(QLT a b)} (updCtxt2-QLT a b upd₁ upd₂) = updCtxt2-QLT _ _ (→updCtxt2-shiftNameUp v cf upd₁) (→updCtxt2-shiftNameUp v cf upd₂)
→updCtxt2-shiftNameUp v {name} {f} cf {.(NUM x)} (updCtxt2-NUM x) = updCtxt2-NUM _
→updCtxt2-shiftNameUp v {name} {f} cf {.(IFLT a b c d)} (updCtxt2-IFLT a b c d upd₁ upd₂ upd₃ upd₄) = updCtxt2-IFLT _ _ _ _ (→updCtxt2-shiftNameUp v cf upd₁) (→updCtxt2-shiftNameUp v cf upd₂) (→updCtxt2-shiftNameUp v cf upd₃) (→updCtxt2-shiftNameUp v cf upd₄)
→updCtxt2-shiftNameUp v {name} {f} cf {.(IFEQ a b c d)} (updCtxt2-IFEQ a b c d upd₁ upd₂ upd₃ upd₄) = updCtxt2-IFEQ _ _ _ _ (→updCtxt2-shiftNameUp v cf upd₁) (→updCtxt2-shiftNameUp v cf upd₂) (→updCtxt2-shiftNameUp v cf upd₃) (→updCtxt2-shiftNameUp v cf upd₄)
→updCtxt2-shiftNameUp v {name} {f} cf {.(SUC a)} (updCtxt2-SUC a upd₁) = updCtxt2-SUC _ (→updCtxt2-shiftNameUp v cf upd₁)
→updCtxt2-shiftNameUp v {name} {f} cf {.(NATREC a b c)} (updCtxt2-NATREC a b c upd₁ upd₂ upd₃) = updCtxt2-NATREC _ _ _ (→updCtxt2-shiftNameUp v cf upd₁) (→updCtxt2-shiftNameUp v cf upd₂) (→updCtxt2-shiftNameUp v cf upd₃)
→updCtxt2-shiftNameUp v {name} {f} cf {.(PI a b)} (updCtxt2-PI a b upd₁ upd₂) = updCtxt2-PI _ _ (→updCtxt2-shiftNameUp v cf upd₁) (→updCtxt2-shiftNameUp v cf upd₂)
→updCtxt2-shiftNameUp v {name} {f} cf {.(LAMBDA a)} (updCtxt2-LAMBDA a upd₁) = updCtxt2-LAMBDA _ (→updCtxt2-shiftNameUp v cf upd₁)
→updCtxt2-shiftNameUp v {name} {f} cf {.(MSEQ s)} (updCtxt2-MSEQ s) = updCtxt2-MSEQ _
→updCtxt2-shiftNameUp v {name} {f} cf {.(MAPP s a)} (updCtxt2-MAPP s a upd₁) = updCtxt2-MAPP _ _ (→updCtxt2-shiftNameUp v cf upd₁)
→updCtxt2-shiftNameUp v {name} {f} cf {.(APPLY a b)} (updCtxt2-APPLY a b upd₁ upd₂) = updCtxt2-APPLY _ _ (→updCtxt2-shiftNameUp v cf upd₁) (→updCtxt2-shiftNameUp v cf upd₂)
→updCtxt2-shiftNameUp v {name} {f} cf {.(FIX a)} (updCtxt2-FIX a upd₁) = updCtxt2-FIX _ (→updCtxt2-shiftNameUp v cf upd₁)
→updCtxt2-shiftNameUp v {name} {f} cf {.(LET a b)} (updCtxt2-LET a b upd₁ upd₂) = updCtxt2-LET _ _ (→updCtxt2-shiftNameUp v cf upd₁) (→updCtxt2-shiftNameUp v cf upd₂)
→updCtxt2-shiftNameUp v {name} {f} cf {.(SUM a b)} (updCtxt2-SUM a b upd₁ upd₂) = updCtxt2-SUM _ _ (→updCtxt2-shiftNameUp v cf upd₁) (→updCtxt2-shiftNameUp v cf upd₂)
→updCtxt2-shiftNameUp v {name} {f} cf {.(PAIR a b)} (updCtxt2-PAIR a b upd₁ upd₂) = updCtxt2-PAIR _ _ (→updCtxt2-shiftNameUp v cf upd₁) (→updCtxt2-shiftNameUp v cf upd₂)
→updCtxt2-shiftNameUp v {name} {f} cf {.(SPREAD a b)} (updCtxt2-SPREAD a b upd₁ upd₂) = updCtxt2-SPREAD _ _ (→updCtxt2-shiftNameUp v cf upd₁) (→updCtxt2-shiftNameUp v cf upd₂)
→updCtxt2-shiftNameUp v {name} {f} cf {.(WT a b c)} (updCtxt2-WT a b c upd₁ upd₂ upd₃) = updCtxt2-WT _ _ _ (→updCtxt2-shiftNameUp v cf upd₁) (→updCtxt2-shiftNameUp v cf upd₂) (→updCtxt2-shiftNameUp v cf upd₃)
→updCtxt2-shiftNameUp v {name} {f} cf {.(SUP a b)} (updCtxt2-SUP a b upd₁ upd₂) = updCtxt2-SUP _ _ (→updCtxt2-shiftNameUp v cf upd₁) (→updCtxt2-shiftNameUp v cf upd₂)
→updCtxt2-shiftNameUp v {name} {f} cf {.(WREC a b)} (updCtxt2-WREC a b upd₁ upd₂) = updCtxt2-WREC _ _ (→updCtxt2-shiftNameUp v cf upd₁) (→updCtxt2-shiftNameUp v cf upd₂)
→updCtxt2-shiftNameUp v {name} {f} cf {.(MT a b c)} (updCtxt2-MT a b c upd₁ upd₂ upd₃) = updCtxt2-MT _ _ _ (→updCtxt2-shiftNameUp v cf upd₁) (→updCtxt2-shiftNameUp v cf upd₂) (→updCtxt2-shiftNameUp v cf upd₃)
→updCtxt2-shiftNameUp v {name} {f} cf {.(SET a b)} (updCtxt2-SET a b upd₁ upd₂) = updCtxt2-SET _ _ (→updCtxt2-shiftNameUp v cf upd₁) (→updCtxt2-shiftNameUp v cf upd₂)
→updCtxt2-shiftNameUp v {name} {f} cf {.(ISECT a b)} (updCtxt2-ISECT a b upd₁ upd₂) = updCtxt2-ISECT _ _ (→updCtxt2-shiftNameUp v cf upd₁) (→updCtxt2-shiftNameUp v cf upd₂)
→updCtxt2-shiftNameUp v {name} {f} cf {.(TUNION a b)} (updCtxt2-TUNION a b upd₁ upd₂) = updCtxt2-TUNION _ _ (→updCtxt2-shiftNameUp v cf upd₁) (→updCtxt2-shiftNameUp v cf upd₂)
→updCtxt2-shiftNameUp v {name} {f} cf {.(UNION a b)} (updCtxt2-UNION a b upd₁ upd₂) = updCtxt2-UNION _ _ (→updCtxt2-shiftNameUp v cf upd₁) (→updCtxt2-shiftNameUp v cf upd₂)
-- →updCtxt2-shiftNameUp v {name} {f} cf {.(QTUNION a b)} (updCtxt2-QTUNION a b upd₁ upd₂) = updCtxt2-QTUNION _ _ (→updCtxt2-shiftNameUp v cf upd₁) (→updCtxt2-shiftNameUp v cf upd₂)
→updCtxt2-shiftNameUp v {name} {f} cf {.(INL a)} (updCtxt2-INL a upd₁) = updCtxt2-INL _ (→updCtxt2-shiftNameUp v cf upd₁)
→updCtxt2-shiftNameUp v {name} {f} cf {.(INR a)} (updCtxt2-INR a upd₁) = updCtxt2-INR _ (→updCtxt2-shiftNameUp v cf upd₁)
→updCtxt2-shiftNameUp v {name} {f} cf {.(DECIDE a b c)} (updCtxt2-DECIDE a b c upd₁ upd₂ upd₃) = updCtxt2-DECIDE _ _ _ (→updCtxt2-shiftNameUp v cf upd₁) (→updCtxt2-shiftNameUp v cf upd₂) (→updCtxt2-shiftNameUp v cf upd₃)
→updCtxt2-shiftNameUp v {name} {f} cf {.(EQ a b c)} (updCtxt2-EQ a b c upd₁ upd₂ upd₃) = updCtxt2-EQ _ _ _ (→updCtxt2-shiftNameUp v cf upd₁) (→updCtxt2-shiftNameUp v cf upd₂) (→updCtxt2-shiftNameUp v cf upd₃)
-- →updCtxt2-shiftNameUp v {name} {f} cf {.(EQB a b c d)} (updCtxt2-EQB a b c d upd₁ upd₂ upd₃ upd₄) = updCtxt2-EQB _ _ _ _ (→updCtxt2-shiftNameUp v cf upd₁) (→updCtxt2-shiftNameUp v cf upd₂) (→updCtxt2-shiftNameUp v cf upd₃) (→updCtxt2-shiftNameUp v cf upd₄)
→updCtxt2-shiftNameUp v {name} {f} cf {.AX} updCtxt2-AX = updCtxt2-AX
→updCtxt2-shiftNameUp v {name} {f} cf {.FREE} updCtxt2-FREE = updCtxt2-FREE
→updCtxt2-shiftNameUp v {name} {f} cf {.(CS name')} (updCtxt2-CS name') = updCtxt2-CS _
→updCtxt2-shiftNameUp v {name} {f} cf {.(NAME name')} (updCtxt2-NAME name' x) = updCtxt2-NAME (sucIf≤ v name') (λ y → x (sucIf≤-inj y))
→updCtxt2-shiftNameUp v {name} {f} cf {.(FRESH a)} (updCtxt2-FRESH a upd₁) =
updCtxt2-FRESH (shiftNameUp (suc v) a) c1
where
c3 : updCtxt2 (sucIf≤ (suc v) (suc name))
(shiftNameUp (suc v) (shiftNameUp 0 f))
(shiftNameUp (suc v) a)
c3 = →updCtxt2-shiftNameUp (suc v) {suc name} (→#shiftNameUp 0 {f} cf) upd₁
c2 : updCtxt2 (suc (sucIf≤ v name))
(shiftNameUp (suc v) (shiftNameUp 0 f))
(shiftNameUp (suc v) a)
c2 rewrite suc-sucIf≤ v name = c3
c1 : updCtxt2 (suc (sucIf≤ v name))
(shiftNameUp 0 (shiftNameUp v f))
(shiftNameUp (suc v) a)
c1 rewrite shiftNameUp-shiftNameUp {0} {v} {f} _≤_.z≤n = c2
→updCtxt2-shiftNameUp v {name} {f} cf {.(LOAD a)} (updCtxt2-LOAD a) = updCtxt2-LOAD _ --(→updCtxt2-shiftNameUp v cf upd₁)
→updCtxt2-shiftNameUp v {name} {f} cf {.(CHOOSE a b)} (updCtxt2-CHOOSE a b upd₁ upd₂) = updCtxt2-CHOOSE _ _ (→updCtxt2-shiftNameUp v cf upd₁) (→updCtxt2-shiftNameUp v cf upd₂)
-- →updCtxt2-shiftNameUp v {name} {f} cf {.(TSQUASH a)} (updCtxt2-TSQUASH a upd₁) = updCtxt2-TSQUASH _ (→updCtxt2-shiftNameUp v cf upd₁)
-- →updCtxt2-shiftNameUp v {name} {f} cf {.(TTRUNC a)} (updCtxt2-TTRUNC a upd₁) = updCtxt2-TTRUNC _ (→updCtxt2-shiftNameUp v cf upd₁)
→updCtxt2-shiftNameUp v {name} {f} cf {.NOWRITE} updCtxt2-NOWRITE = updCtxt2-NOWRITE
→updCtxt2-shiftNameUp v {name} {f} cf {.NOREAD} updCtxt2-NOREAD = updCtxt2-NOREAD
→updCtxt2-shiftNameUp v {name} {f} cf {.(SUBSING a)} (updCtxt2-SUBSING a upd₁) = updCtxt2-SUBSING _ (→updCtxt2-shiftNameUp v cf upd₁)
→updCtxt2-shiftNameUp v {name} {f} cf {.PURE} updCtxt2-PURE = updCtxt2-PURE
→updCtxt2-shiftNameUp v {name} {f} cf {.NOSEQ} updCtxt2-NOSEQ = updCtxt2-NOSEQ
→updCtxt2-shiftNameUp v {name} {f} cf {.NOENC} updCtxt2-NOENC = updCtxt2-NOENC
→updCtxt2-shiftNameUp v {name} {f} cf {.(TERM a)} (updCtxt2-TERM a upd₁) = updCtxt2-TERM _ (→updCtxt2-shiftNameUp v cf upd₁)
→updCtxt2-shiftNameUp v {name} {f} cf {.(ENC a)} (updCtxt2-ENC a upd₁) = updCtxt2-ENC _ (→updCtxt2-shiftNameUp v cf upd₁)
→updCtxt2-shiftNameUp v {name} {f} cf {.(PARTIAL a)} (updCtxt2-PARTIAL a upd₁) = updCtxt2-PARTIAL _ (→updCtxt2-shiftNameUp v cf upd₁)
→updCtxt2-shiftNameUp v {name} {f} cf {.(FFDEFS a b)} (updCtxt2-FFDEFS a b upd₁ upd₂) = updCtxt2-FFDEFS _ _ (→updCtxt2-shiftNameUp v cf upd₁) (→updCtxt2-shiftNameUp v cf upd₂)
→updCtxt2-shiftNameUp v {name} {f} cf {.(UNIV x)} (updCtxt2-UNIV x) = updCtxt2-UNIV _
→updCtxt2-shiftNameUp v {name} {f} cf {.(LIFT a)} (updCtxt2-LIFT a upd₁) = updCtxt2-LIFT _ (→updCtxt2-shiftNameUp v cf upd₁)
→updCtxt2-shiftNameUp v {name} {f} cf {.(LOWER a)} (updCtxt2-LOWER a upd₁) = updCtxt2-LOWER _ (→updCtxt2-shiftNameUp v cf upd₁)
→updCtxt2-shiftNameUp v {name} {f} cf {.(SHRINK a)} (updCtxt2-SHRINK a upd₁) = updCtxt2-SHRINK _ (→updCtxt2-shiftNameUp v cf upd₁)
→updCtxt2-shiftNameUp v {name} {f} cf {.(upd name f)} updCtxt2-upd = c2
where
c1 : updCtxt2 (sucIf≤ v name) (shiftNameUp v f) (upd (sucIf≤ v name) (shiftNameUp v f))
c1 = updCtxt2-upd
c2 : updCtxt2 (sucIf≤ v name) (shiftNameUp v f)
(LAMBDA (LET (VAR 0)
(LET (IFLT (APPLY (CS (sucIf≤ v name)) (NUM 0)) (VAR 0)
(CHOOSE (NAME (sucIf≤ v name)) (VAR 0)) AX)
(APPLY (shiftNameUp v (shiftUp 0 f)) (VAR (sucIf≤ 0 0))))))
c2 rewrite sym (shiftUp-shiftNameUp 0 v f) = c1
→updCtxt2-shiftNameUp0 : {name : Name} {f : Term} (cf : # f) {a : Term}
→ updCtxt2 name f a
→ updCtxt2 (suc name) (shiftNameUp 0 f) (shiftNameUp 0 a)
→updCtxt2-shiftNameUp0 {name} {f} cf {a} dif
rewrite suc≡sucIf≤0 name =
→updCtxt2-shiftNameUp 0 {name} cf dif
abstract
updCtxt2-subv : {name : Name} {f : Term} (cf : # f) (v : Var) {a b : Term}
→ updCtxt2 name f a
→ updCtxt2 name f b
→ updCtxt2 name f (subv v b a)
updCtxt2-subv {name} {f} cf v {.(VAR x)} {b} (updCtxt2-VAR x) updb with x ≟ v
... | yes p = updb
... | no p = updCtxt2-VAR _
-- updCtxt2-subv {name} {f} cf v {.NAT} {b} updCtxt2-NAT updb = updCtxt2-NAT
updCtxt2-subv {name} {f} cf v {.QNAT} {b} updCtxt2-QNAT updb = updCtxt2-QNAT
-- updCtxt2-subv {name} {f} cf v {.TNAT} {b} updCtxt2-TNAT updb = updCtxt2-TNAT
updCtxt2-subv {name} {f} cf v {.(LT a b₁)} {b} (updCtxt2-LT a b₁ upda upda₁) updb = updCtxt2-LT _ _ (updCtxt2-subv cf v upda updb) (updCtxt2-subv cf v upda₁ updb)
updCtxt2-subv {name} {f} cf v {.(QLT a b₁)} {b} (updCtxt2-QLT a b₁ upda upda₁) updb = updCtxt2-QLT _ _ (updCtxt2-subv cf v upda updb) (updCtxt2-subv cf v upda₁ updb)
updCtxt2-subv {name} {f} cf v {.(NUM x)} {b} (updCtxt2-NUM x) updb = updCtxt2-NUM _
updCtxt2-subv {name} {f} cf v {.(IFLT a b₁ c d)} {b} (updCtxt2-IFLT a b₁ c d upda upda₁ upda₂ upda₃) updb = updCtxt2-IFLT _ _ _ _ (updCtxt2-subv cf v upda updb) (updCtxt2-subv cf v upda₁ updb) (updCtxt2-subv cf v upda₂ updb) (updCtxt2-subv cf v upda₃ updb)
updCtxt2-subv {name} {f} cf v {.(IFEQ a b₁ c d)} {b} (updCtxt2-IFEQ a b₁ c d upda upda₁ upda₂ upda₃) updb = updCtxt2-IFEQ _ _ _ _ (updCtxt2-subv cf v upda updb) (updCtxt2-subv cf v upda₁ updb) (updCtxt2-subv cf v upda₂ updb) (updCtxt2-subv cf v upda₃ updb)
updCtxt2-subv {name} {f} cf v {.(SUC a)} {b} (updCtxt2-SUC a upda) updb = updCtxt2-SUC _ (updCtxt2-subv cf v upda updb)
updCtxt2-subv {name} {f} cf v {.(NATREC a a₁ a₂)} {b} (updCtxt2-NATREC a a₁ a₂ upda upda₁ upda₂) updb = updCtxt2-NATREC _ _ _ (updCtxt2-subv cf v upda updb) (updCtxt2-subv cf v upda₁ updb) (updCtxt2-subv cf v upda₂ updb)
updCtxt2-subv {name} {f} cf v {.(PI a b₁)} {b} (updCtxt2-PI a b₁ upda upda₁) updb = updCtxt2-PI _ _ (updCtxt2-subv cf v upda updb) (updCtxt2-subv cf (suc v) upda₁ (→updCtxt2-shiftUp 0 cf updb))
updCtxt2-subv {name} {f} cf v {.(LAMBDA a)} {b} (updCtxt2-LAMBDA a upda) updb = updCtxt2-LAMBDA _ (updCtxt2-subv cf (suc v) upda (→updCtxt2-shiftUp 0 cf updb))
updCtxt2-subv {name} {f} cf v {.(MSEQ s)} {b} (updCtxt2-MSEQ s) updb = updCtxt2-MSEQ _
updCtxt2-subv {name} {f} cf v {.(MAPP s a)} {b} (updCtxt2-MAPP s a upda) updb = updCtxt2-MAPP _ _ (updCtxt2-subv cf v upda updb)
updCtxt2-subv {name} {f} cf v {.(APPLY a b₁)} {b} (updCtxt2-APPLY a b₁ upda upda₁) updb = updCtxt2-APPLY _ _ (updCtxt2-subv cf v upda updb) (updCtxt2-subv cf v upda₁ updb)
updCtxt2-subv {name} {f} cf v {.(FIX a)} {b} (updCtxt2-FIX a upda) updb = updCtxt2-FIX _ (updCtxt2-subv cf v upda updb)
updCtxt2-subv {name} {f} cf v {.(LET a b₁)} {b} (updCtxt2-LET a b₁ upda upda₁) updb = updCtxt2-LET _ _ (updCtxt2-subv cf v upda updb) (updCtxt2-subv cf (suc v) upda₁ (→updCtxt2-shiftUp 0 cf updb))
updCtxt2-subv {name} {f} cf v {.(SUM a b₁)} {b} (updCtxt2-SUM a b₁ upda upda₁) updb = updCtxt2-SUM _ _ (updCtxt2-subv cf v upda updb) (updCtxt2-subv cf (suc v) upda₁ (→updCtxt2-shiftUp 0 cf updb))
updCtxt2-subv {name} {f} cf v {.(PAIR a b₁)} {b} (updCtxt2-PAIR a b₁ upda upda₁) updb = updCtxt2-PAIR _ _ (updCtxt2-subv cf v upda updb) (updCtxt2-subv cf v upda₁ updb)
updCtxt2-subv {name} {f} cf v {.(SPREAD a b₁)} {b} (updCtxt2-SPREAD a b₁ upda upda₁) updb = updCtxt2-SPREAD _ _ (updCtxt2-subv cf v upda updb) (updCtxt2-subv cf (suc (suc v)) upda₁ (→updCtxt2-shiftUp 0 cf (→updCtxt2-shiftUp 0 cf updb)))
updCtxt2-subv {name} {f} cf v {.(WT a b₁ c)} {b} (updCtxt2-WT a b₁ c upda upda₁ upda₂) updb = updCtxt2-WT _ _ _ (updCtxt2-subv cf v upda updb) (updCtxt2-subv cf (suc v) upda₁ (→updCtxt2-shiftUp 0 cf updb)) (updCtxt2-subv cf v upda₂ updb)
updCtxt2-subv {name} {f} cf v {.(SUP a b₁)} {b} (updCtxt2-SUP a b₁ upda upda₁) updb = updCtxt2-SUP _ _ (updCtxt2-subv cf v upda updb) (updCtxt2-subv cf v upda₁ updb)
updCtxt2-subv {name} {f} cf v {.(WREC a b₁)} {b} (updCtxt2-WREC a b₁ upda upda₁) updb = updCtxt2-WREC _ _ (updCtxt2-subv cf v upda updb) (updCtxt2-subv cf (suc (suc (suc v))) upda₁ (→updCtxt2-shiftUp 0 cf (→updCtxt2-shiftUp 0 cf (→updCtxt2-shiftUp 0 cf updb))))
updCtxt2-subv {name} {f} cf v {.(MT a b₁ c)} {b} (updCtxt2-MT a b₁ c upda upda₁ upda₂) updb = updCtxt2-MT _ _ _ (updCtxt2-subv cf v upda updb) (updCtxt2-subv cf (suc v) upda₁ (→updCtxt2-shiftUp 0 cf updb)) (updCtxt2-subv cf v upda₂ updb)
updCtxt2-subv {name} {f} cf v {.(SET a b₁)} {b} (updCtxt2-SET a b₁ upda upda₁) updb = updCtxt2-SET _ _ (updCtxt2-subv cf v upda updb) (updCtxt2-subv cf (suc v) upda₁ (→updCtxt2-shiftUp 0 cf updb))
updCtxt2-subv {name} {f} cf v {.(ISECT a b₁)} {b} (updCtxt2-ISECT a b₁ upda upda₁) updb = updCtxt2-ISECT _ _ (updCtxt2-subv cf v upda updb) (updCtxt2-subv cf v upda₁ updb)
updCtxt2-subv {name} {f} cf v {.(TUNION a b₁)} {b} (updCtxt2-TUNION a b₁ upda upda₁) updb = updCtxt2-TUNION _ _ (updCtxt2-subv cf v upda updb) (updCtxt2-subv cf (suc v) upda₁ (→updCtxt2-shiftUp 0 cf updb))
updCtxt2-subv {name} {f} cf v {.(UNION a b₁)} {b} (updCtxt2-UNION a b₁ upda upda₁) updb = updCtxt2-UNION _ _ (updCtxt2-subv cf v upda updb) (updCtxt2-subv cf v upda₁ updb)
-- updCtxt2-subv {name} {f} cf v {.(QTUNION a b₁)} {b} (updCtxt2-QTUNION a b₁ upda upda₁) updb = updCtxt2-QTUNION _ _ (updCtxt2-subv cf v upda updb) (updCtxt2-subv cf v upda₁ updb)
updCtxt2-subv {name} {f} cf v {.(INL a)} {b} (updCtxt2-INL a upda) updb = updCtxt2-INL _ (updCtxt2-subv cf v upda updb)
updCtxt2-subv {name} {f} cf v {.(INR a)} {b} (updCtxt2-INR a upda) updb = updCtxt2-INR _ (updCtxt2-subv cf v upda updb)
updCtxt2-subv {name} {f} cf v {.(DECIDE a b₁ c)} {b} (updCtxt2-DECIDE a b₁ c upda upda₁ upda₂) updb = updCtxt2-DECIDE _ _ _ (updCtxt2-subv cf v upda updb) (updCtxt2-subv cf (suc v) upda₁ (→updCtxt2-shiftUp 0 cf updb)) (updCtxt2-subv cf (suc v) upda₂ (→updCtxt2-shiftUp 0 cf updb))
updCtxt2-subv {name} {f} cf v {.(EQ a b₁ c)} {b} (updCtxt2-EQ a b₁ c upda upda₁ upda₂) updb = updCtxt2-EQ _ _ _ (updCtxt2-subv cf v upda updb) (updCtxt2-subv cf v upda₁ updb) (updCtxt2-subv cf v upda₂ updb)
-- updCtxt2-subv {name} {f} cf v {.(EQB a b₁ c d)} {b} (updCtxt2-EQB a b₁ c d upda upda₁ upda₂ upda₃) updb = updCtxt2-EQB _ _ _ _ (updCtxt2-subv cf v upda updb) (updCtxt2-subv cf v upda₁ updb) (updCtxt2-subv cf v upda₂ updb) (updCtxt2-subv cf v upda₃ updb)
updCtxt2-subv {name} {f} cf v {.AX} {b} updCtxt2-AX updb = updCtxt2-AX
updCtxt2-subv {name} {f} cf v {.FREE} {b} updCtxt2-FREE updb = updCtxt2-FREE
updCtxt2-subv {name} {f} cf v {.(CS name')} {b} (updCtxt2-CS name') updb = updCtxt2-CS _
updCtxt2-subv {name} {f} cf v {.(NAME name')} {b} (updCtxt2-NAME name' x) updb = updCtxt2-NAME _ x
updCtxt2-subv {name} {f} cf v {.(FRESH a)} {b} (updCtxt2-FRESH a upda) updb = updCtxt2-FRESH _ (updCtxt2-subv (→#shiftNameUp 0 {f} cf) v upda (→updCtxt2-shiftNameUp0 {name} cf updb))
updCtxt2-subv {name} {f} cf v {.(LOAD a)} {b} (updCtxt2-LOAD a) updb = updCtxt2-LOAD _ --upda --updCtxt2-LOAD _ (updCtxt2-subv cf v upda updb)
updCtxt2-subv {name} {f} cf v {.(CHOOSE a b₁)} {b} (updCtxt2-CHOOSE a b₁ upda upda₁) updb = updCtxt2-CHOOSE _ _ (updCtxt2-subv cf v upda updb) (updCtxt2-subv cf v upda₁ updb)
-- updCtxt2-subv {name} {f} cf v {.(TSQUASH a)} {b} (updCtxt2-TSQUASH a upda) updb = updCtxt2-TSQUASH _ (updCtxt2-subv cf v upda updb)
-- updCtxt2-subv {name} {f} cf v {.(TTRUNC a)} {b} (updCtxt2-TTRUNC a upda) updb = updCtxt2-TTRUNC _ (updCtxt2-subv cf v upda updb)
updCtxt2-subv {name} {f} cf v {.NOWRITE} {b} updCtxt2-NOWRITE updb = updCtxt2-NOWRITE
updCtxt2-subv {name} {f} cf v {.NOREAD} {b} updCtxt2-NOREAD updb = updCtxt2-NOREAD
updCtxt2-subv {name} {f} cf v {.(SUBSING a)} {b} (updCtxt2-SUBSING a upda) updb = updCtxt2-SUBSING _ (updCtxt2-subv cf v upda updb)
updCtxt2-subv {name} {f} cf v {.PURE} {b} updCtxt2-PURE updb = updCtxt2-PURE
updCtxt2-subv {name} {f} cf v {.NOSEQ} {b} updCtxt2-NOSEQ updb = updCtxt2-NOSEQ
updCtxt2-subv {name} {f} cf v {.NOENC} {b} updCtxt2-NOENC updb = updCtxt2-NOENC
updCtxt2-subv {name} {f} cf v {.(TERM a)} {b} (updCtxt2-TERM a upda) updb = updCtxt2-TERM _ (updCtxt2-subv cf v upda updb)
updCtxt2-subv {name} {f} cf v {.(ENC a)} {b} (updCtxt2-ENC a upda) updb = updCtxt2-ENC _ upda
updCtxt2-subv {name} {f} cf v {.(PARTIAL a)} {b} (updCtxt2-PARTIAL a upda) updb = updCtxt2-PARTIAL _ (updCtxt2-subv cf v upda updb)
updCtxt2-subv {name} {f} cf v {.(FFDEFS a b₁)} {b} (updCtxt2-FFDEFS a b₁ upda upda₁) updb = updCtxt2-FFDEFS _ _ (updCtxt2-subv cf v upda updb) (updCtxt2-subv cf v upda₁ updb)
updCtxt2-subv {name} {f} cf v {.(UNIV x)} {b} (updCtxt2-UNIV x) updb = updCtxt2-UNIV _
updCtxt2-subv {name} {f} cf v {.(LIFT a)} {b} (updCtxt2-LIFT a upda) updb = updCtxt2-LIFT _ (updCtxt2-subv cf v upda updb)
updCtxt2-subv {name} {f} cf v {.(LOWER a)} {b} (updCtxt2-LOWER a upda) updb = updCtxt2-LOWER _ (updCtxt2-subv cf v upda updb)
updCtxt2-subv {name} {f} cf v {.(SHRINK a)} {b} (updCtxt2-SHRINK a upda) updb = updCtxt2-SHRINK _ (updCtxt2-subv cf v upda updb)
updCtxt2-subv {name} {f} cf v {.(upd name f)} {b} updCtxt2-upd updb
rewrite sucIf≤00
| subv# (suc (suc (suc v))) (shiftUp 0 (shiftUp 0 (shiftUp 0 b))) (shiftUp 0 f) (→#shiftUp 0 {f} cf)
= updCtxt2-upd
updCtxt2-sub : {name : Name} {f : Term} (cf : # f) {a b : Term}
→ updCtxt2 name f a
→ updCtxt2 name f b
→ updCtxt2 name f (sub b a)
updCtxt2-sub {name} {f} cf {a} {b} d₁ d₂ =
→updCtxt2-shiftDown 0 cf (updCtxt2-subv {name} {f} cf 0 {a} {shiftUp 0 b} d₁ (→updCtxt2-shiftUp 0 cf d₂))
updCtxt2-LAMBDA→ : {name : Name} {f t : Term}
→ updCtxt2 name f (LAMBDA t)
→ updCtxt2 name f t ⊎ t ≡ updBody name f
updCtxt2-LAMBDA→ {name} {f} {t} (updCtxt2-LAMBDA .t u) = inj₁ u
updCtxt2-LAMBDA→ {name} {f} {.(updBody name f)} updCtxt2-upd = inj₂ refl
updCtxt2-NAME→ : {name name' : Name} {f : Term}
→ updCtxt2 name f (NAME name')
→ ¬ name' ≡ name
updCtxt2-NAME→ {name} {name'} {f} (updCtxt2-NAME .name' x) = x
updCtxt2-PAIR→₁ : {name : Name} {f a b : Term}
→ updCtxt2 name f (PAIR a b)
→ updCtxt2 name f a
updCtxt2-PAIR→₁ {name} {f} {a} {b} (updCtxt2-PAIR .a .b ca cb) = ca
updCtxt2-PAIR→₂ : {name : Name} {f a b : Term}
→ updCtxt2 name f (PAIR a b)
→ updCtxt2 name f b
updCtxt2-PAIR→₂ {name} {f} {a} {b} (updCtxt2-PAIR .a .b ca cb) = cb
updCtxt2-SUP→₁ : {name : Name} {f a b : Term}
→ updCtxt2 name f (SUP a b)
→ updCtxt2 name f a
updCtxt2-SUP→₁ {name} {f} {a} {b} (updCtxt2-SUP .a .b ca cb) = ca
updCtxt2-SUP→₂ : {name : Name} {f a b : Term}
→ updCtxt2 name f (SUP a b)
→ updCtxt2 name f b
updCtxt2-SUP→₂ {name} {f} {a} {b} (updCtxt2-SUP .a .b ca cb) = cb
updCtxt2-INL→ : {name : Name} {f a : Term}
→ updCtxt2 name f (INL a)
→ updCtxt2 name f a
updCtxt2-INL→ {name} {f} {a} (updCtxt2-INL .a ca) = ca
updCtxt2-INR→ : {name : Name} {f a : Term}
→ updCtxt2 name f (INR a)
→ updCtxt2 name f a
updCtxt2-INR→ {name} {f} {a} (updCtxt2-INR .a ca) = ca
¬∈names-APPLY : {name : Name} {a b : Term}
→ ¬ name ∈ names a
→ ¬ name ∈ names b
→ ¬ name ∈ names (APPLY a b)
¬∈names-APPLY {name} {a} {b} na nb i with ∈-++⁻ (names a) i
... | inj₁ p = na p
... | inj₂ p = nb p
¬∈names-NUM : {name : Name} {n : ℕ}
→ ¬ name ∈ names (NUM n)
¬∈names-NUM {name} {n} ()
abstract
updCtxt2-refl : (name : Name) (f t : Term)
→ ¬ name ∈ names t
→ updCtxt2 name f t
updCtxt2-refl name f (VAR x) nn = updCtxt2-VAR _
-- updCtxt2-refl name f NAT nn = updCtxt2-NAT
updCtxt2-refl name f QNAT nn = updCtxt2-QNAT
-- updCtxt2-refl name f TNAT nn = updCtxt2-TNAT
updCtxt2-refl name f (LT t t₁) nn = updCtxt2-LT _ _ (updCtxt2-refl name f t (¬∈++2→¬∈1 nn)) (updCtxt2-refl name f t₁ (¬∈++2→¬∈2 nn))
updCtxt2-refl name f (QLT t t₁) nn = updCtxt2-QLT _ _ (updCtxt2-refl name f t (¬∈++2→¬∈1 nn)) (updCtxt2-refl name f t₁ (¬∈++2→¬∈2 nn))
updCtxt2-refl name f (NUM x) nn = updCtxt2-NUM _
updCtxt2-refl name f (IFLT t t₁ t₂ t₃) nn = updCtxt2-IFLT _ _ _ _ (updCtxt2-refl name f t (¬∈++4→¬∈1 {_} {_} {names t} {names t₁} {names t₂} {names t₃} nn)) (updCtxt2-refl name f t₁ (¬∈++4→¬∈2 {_} {_} {names t} {names t₁} {names t₂} {names t₃} nn)) (updCtxt2-refl name f t₂ (¬∈++4→¬∈3 {_} {_} {names t} {names t₁} {names t₂} {names t₃} nn)) (updCtxt2-refl name f t₃ (¬∈++4→¬∈4 {_} {_} {names t} {names t₁} {names t₂} {names t₃} nn))
updCtxt2-refl name f (IFEQ t t₁ t₂ t₃) nn = updCtxt2-IFEQ _ _ _ _ (updCtxt2-refl name f t (¬∈++4→¬∈1 {_} {_} {names t} {names t₁} {names t₂} {names t₃} nn)) (updCtxt2-refl name f t₁ (¬∈++4→¬∈2 {_} {_} {names t} {names t₁} {names t₂} {names t₃} nn)) (updCtxt2-refl name f t₂ (¬∈++4→¬∈3 {_} {_} {names t} {names t₁} {names t₂} {names t₃} nn)) (updCtxt2-refl name f t₃ (¬∈++4→¬∈4 {_} {_} {names t} {names t₁} {names t₂} {names t₃} nn))
updCtxt2-refl name f (SUC t) nn = updCtxt2-SUC _ (updCtxt2-refl name f t nn)
updCtxt2-refl name f (NATREC t t₁ t₂) nn = updCtxt2-NATREC _ _ _ (updCtxt2-refl name f t (¬∈++3→¬∈1 {_} {_} {names t} {names t₁} {names t₂} nn)) (updCtxt2-refl name f t₁ (¬∈++3→¬∈2 {_} {_} {names t} {names t₁} {names t₂} nn)) (updCtxt2-refl name f t₂ (¬∈++3→¬∈3 {_} {_} {names t} {names t₁} {names t₂} nn))
updCtxt2-refl name f (PI t t₁) nn = updCtxt2-PI _ _ (updCtxt2-refl name f t (¬∈++2→¬∈1 nn)) (updCtxt2-refl name f t₁ (¬∈++2→¬∈2 nn))
updCtxt2-refl name f (LAMBDA t) nn = updCtxt2-LAMBDA _ (updCtxt2-refl name f t nn)
updCtxt2-refl name f (MSEQ s) nn = updCtxt2-MSEQ _
updCtxt2-refl name f (MAPP s t) nn = updCtxt2-MAPP _ _ (updCtxt2-refl name f t nn)
updCtxt2-refl name f (APPLY t t₁) nn = updCtxt2-APPLY _ _ (updCtxt2-refl name f t (¬∈++2→¬∈1 nn)) (updCtxt2-refl name f t₁ (¬∈++2→¬∈2 nn))
updCtxt2-refl name f (FIX t) nn = updCtxt2-FIX _ (updCtxt2-refl name f t nn)
updCtxt2-refl name f (LET t t₁) nn = updCtxt2-LET _ _ (updCtxt2-refl name f t (¬∈++2→¬∈1 nn)) (updCtxt2-refl name f t₁ (¬∈++2→¬∈2 nn))
updCtxt2-refl name f (SUM t t₁) nn = updCtxt2-SUM _ _ (updCtxt2-refl name f t (¬∈++2→¬∈1 nn)) (updCtxt2-refl name f t₁ (¬∈++2→¬∈2 nn))
updCtxt2-refl name f (PAIR t t₁) nn = updCtxt2-PAIR _ _ (updCtxt2-refl name f t (¬∈++2→¬∈1 nn)) (updCtxt2-refl name f t₁ (¬∈++2→¬∈2 nn))
updCtxt2-refl name f (SPREAD t t₁) nn = updCtxt2-SPREAD _ _ (updCtxt2-refl name f t (¬∈++2→¬∈1 nn)) (updCtxt2-refl name f t₁ (¬∈++2→¬∈2 nn))
updCtxt2-refl name f (WT t t₁ t₂) nn = updCtxt2-WT _ _ _ (updCtxt2-refl name f t (¬∈++3→¬∈1 {_} {_} {names t} {names t₁} {names t₂} nn)) (updCtxt2-refl name f t₁ (¬∈++3→¬∈2 {_} {_} {names t} {names t₁} {names t₂} nn)) (updCtxt2-refl name f t₂ (¬∈++3→¬∈3 {_} {_} {names t} {names t₁} {names t₂} nn))
updCtxt2-refl name f (SUP t t₁) nn = updCtxt2-SUP _ _ (updCtxt2-refl name f t (¬∈++2→¬∈1 nn)) (updCtxt2-refl name f t₁ (¬∈++2→¬∈2 nn))
updCtxt2-refl name f (WREC t t₁) nn = updCtxt2-WREC _ _ (updCtxt2-refl name f t (¬∈++2→¬∈1 nn)) (updCtxt2-refl name f t₁ (¬∈++2→¬∈2 nn))
updCtxt2-refl name f (MT t t₁ t₂) nn = updCtxt2-MT _ _ _ (updCtxt2-refl name f t (¬∈++3→¬∈1 {_} {_} {names t} {names t₁} {names t₂} nn)) (updCtxt2-refl name f t₁ (¬∈++3→¬∈2 {_} {_} {names t} {names t₁} {names t₂} nn)) (updCtxt2-refl name f t₂ (¬∈++3→¬∈3 {_} {_} {names t} {names t₁} {names t₂} nn))
updCtxt2-refl name f (SET t t₁) nn = updCtxt2-SET _ _ (updCtxt2-refl name f t (¬∈++2→¬∈1 nn)) (updCtxt2-refl name f t₁ (¬∈++2→¬∈2 nn))
updCtxt2-refl name f (TUNION t t₁) nn = updCtxt2-TUNION _ _ (updCtxt2-refl name f t (¬∈++2→¬∈1 nn)) (updCtxt2-refl name f t₁ (¬∈++2→¬∈2 nn))
updCtxt2-refl name f (ISECT t t₁) nn = updCtxt2-ISECT _ _ (updCtxt2-refl name f t (¬∈++2→¬∈1 nn)) (updCtxt2-refl name f t₁ (¬∈++2→¬∈2 nn))
updCtxt2-refl name f (UNION t t₁) nn = updCtxt2-UNION _ _ (updCtxt2-refl name f t (¬∈++2→¬∈1 nn)) (updCtxt2-refl name f t₁ (¬∈++2→¬∈2 nn))
-- updCtxt2-refl name f (QTUNION t t₁) nn = updCtxt2-QTUNION _ _ (updCtxt2-refl name f t (¬∈++2→¬∈1 nn)) (updCtxt2-refl name f t₁ (¬∈++2→¬∈2 nn))
updCtxt2-refl name f (INL t) nn = updCtxt2-INL _ (updCtxt2-refl name f t nn)
updCtxt2-refl name f (INR t) nn = updCtxt2-INR _ (updCtxt2-refl name f t nn)
updCtxt2-refl name f (DECIDE t t₁ t₂) nn = updCtxt2-DECIDE _ _ _ (updCtxt2-refl name f t (¬∈++3→¬∈1 {_} {_} {names t} {names t₁} {names t₂} nn)) (updCtxt2-refl name f t₁ (¬∈++3→¬∈2 {_} {_} {names t} {names t₁} {names t₂} nn)) (updCtxt2-refl name f t₂ (¬∈++3→¬∈3 {_} {_} {names t} {names t₁} {names t₂} nn))
updCtxt2-refl name f (EQ t t₁ t₂) nn = updCtxt2-EQ _ _ _ (updCtxt2-refl name f t (¬∈++3→¬∈1 {_} {_} {names t} {names t₁} {names t₂} nn)) (updCtxt2-refl name f t₁ (¬∈++3→¬∈2 {_} {_} {names t} {names t₁} {names t₂} nn)) (updCtxt2-refl name f t₂ (¬∈++3→¬∈3 {_} {_} {names t} {names t₁} {names t₂} nn))
-- updCtxt2-refl name f (EQB t t₁ t₂ t₃) nn = updCtxt2-EQB _ _ _ _ (updCtxt2-refl name f t (¬∈++4→¬∈1 {_} {_} {names t} {names t₁} {names t₂} {names t₃} nn)) (updCtxt2-refl name f t₁ (¬∈++4→¬∈2 {_} {_} {names t} {names t₁} {names t₂} {names t₃} nn)) (updCtxt2-refl name f t₂ (¬∈++4→¬∈3 {_} {_} {names t} {names t₁} {names t₂} {names t₃} nn)) (updCtxt2-refl name f t₃ (¬∈++4→¬∈4 {_} {_} {names t} {names t₁} {names t₂} {names t₃} nn))
updCtxt2-refl name f AX nn = updCtxt2-AX
updCtxt2-refl name f FREE nn = updCtxt2-FREE
updCtxt2-refl name f (CS x) nn = updCtxt2-CS _
updCtxt2-refl name f (NAME x) nn = updCtxt2-NAME x (λ z → nn (here (sym z)))
updCtxt2-refl name f (FRESH t) nn = updCtxt2-FRESH t (updCtxt2-refl (suc name) (shiftNameUp 0 f) t (λ z → nn (suc→∈lowerNames {name} {names t} z)))
updCtxt2-refl name f (LOAD t) nn = updCtxt2-LOAD t --(updCtxt2-refl name f t nn)
updCtxt2-refl name f (CHOOSE t t₁) nn = updCtxt2-CHOOSE _ _ (updCtxt2-refl name f t (¬∈++2→¬∈1 nn)) (updCtxt2-refl name f t₁ (¬∈++2→¬∈2 nn))
-- updCtxt2-refl name f (TSQUASH t) nn = updCtxt2-TSQUASH _ (updCtxt2-refl name f t nn)
-- updCtxt2-refl name f (TTRUNC t) nn = updCtxt2-TTRUNC _ (updCtxt2-refl name f t nn)
updCtxt2-refl name f NOWRITE nn = updCtxt2-NOWRITE
updCtxt2-refl name f NOREAD nn = updCtxt2-NOREAD
updCtxt2-refl name f (SUBSING t) nn = updCtxt2-SUBSING _ (updCtxt2-refl name f t nn)
updCtxt2-refl name f (PARTIAL t) nn = updCtxt2-PARTIAL _ (updCtxt2-refl name f t nn)
updCtxt2-refl name f (FFDEFS t t₁) nn = updCtxt2-FFDEFS _ _ (updCtxt2-refl name f t (¬∈++2→¬∈1 nn)) (updCtxt2-refl name f t₁ (¬∈++2→¬∈2 nn))
updCtxt2-refl name f PURE nn = updCtxt2-PURE
updCtxt2-refl name f NOSEQ nn = updCtxt2-NOSEQ
updCtxt2-refl name f NOENC nn = updCtxt2-NOENC
updCtxt2-refl name f (TERM t) nn = updCtxt2-TERM _ (updCtxt2-refl name f t nn)
updCtxt2-refl name f (ENC t) nn = updCtxt2-ENC _ (updCtxt2-refl name f t nn)
updCtxt2-refl name f (UNIV x) nn = updCtxt2-UNIV _
updCtxt2-refl name f (LIFT t) nn = updCtxt2-LIFT _ (updCtxt2-refl name f t nn)
updCtxt2-refl name f (LOWER t) nn = updCtxt2-LOWER _ (updCtxt2-refl name f t nn)
updCtxt2-refl name f (SHRINK t) nn = updCtxt2-SHRINK _ (updCtxt2-refl name f t nn)
updCtxt2-shiftNameUp-LAMBDA→ : (v : Var) {name : Name} {f : Term} (cf : # f) {a t : Term}
→ t ≡ shiftNameUp v a
→ updCtxt2 (sucIf≤ v name) (shiftNameUp v f) (LAMBDA t)
→ (updCtxt2 (sucIf≤ v name) (shiftNameUp v f) (shiftNameUp v a) → updCtxt2 name f a)
→ updCtxt2 name f (LAMBDA a)
updCtxt2-shiftNameUp-LAMBDA→ v {name} {f} cf {a} {t} e (updCtxt2-LAMBDA .t upd₁) ind rewrite e = updCtxt2-LAMBDA _ (ind upd₁)
updCtxt2-shiftNameUp-LAMBDA→ v {name} {f} cf {a} {.(updBody (sucIf≤ v name) (shiftNameUp v f))} e updCtxt2-upd ind
rewrite updBody≡shiftNameUp→ v name f a e = updCtxt2-upd
abstract
updCtxt2-shiftNameUp→ : (v : Var) {name : Name} {f : Term} (cf : # f) {a : Term}
→ updCtxt2 (sucIf≤ v name) (shiftNameUp v f) (shiftNameUp v a)
→ updCtxt2 name f a
updCtxt2-shiftNameUp→ v {name} {f} cf {VAR x} (updCtxt2-VAR .x) = updCtxt2-VAR _
-- updCtxt2-shiftNameUp→ v {name} {f} cf {NAT} upd = updCtxt2-NAT
updCtxt2-shiftNameUp→ v {name} {f} cf {QNAT} upd = updCtxt2-QNAT
-- updCtxt2-shiftNameUp→ v {name} {f} cf {TNAT} upd = updCtxt2-TNAT
updCtxt2-shiftNameUp→ v {name} {f} cf {LT a a₁} (updCtxt2-LT .(shiftNameUp v a) .(shiftNameUp v a₁) upd₁ upd₂) = updCtxt2-LT _ _ (updCtxt2-shiftNameUp→ v cf upd₁) (updCtxt2-shiftNameUp→ v cf upd₂)
updCtxt2-shiftNameUp→ v {name} {f} cf {QLT a a₁} (updCtxt2-QLT .(shiftNameUp v a) .(shiftNameUp v a₁) upd₁ upd₂) = updCtxt2-QLT _ _ (updCtxt2-shiftNameUp→ v cf upd₁) (updCtxt2-shiftNameUp→ v cf upd₂)
updCtxt2-shiftNameUp→ v {name} {f} cf {NUM x} upd = updCtxt2-NUM _
updCtxt2-shiftNameUp→ v {name} {f} cf {IFLT a a₁ a₂ a₃} (updCtxt2-IFLT .(shiftNameUp v a) .(shiftNameUp v a₁) .(shiftNameUp v a₂) .(shiftNameUp v a₃) upd₁ upd₂ upd₃ upd₄) = updCtxt2-IFLT _ _ _ _ (updCtxt2-shiftNameUp→ v cf upd₁) (updCtxt2-shiftNameUp→ v cf upd₂) (updCtxt2-shiftNameUp→ v cf upd₃) (updCtxt2-shiftNameUp→ v cf upd₄)
updCtxt2-shiftNameUp→ v {name} {f} cf {IFEQ a a₁ a₂ a₃} (updCtxt2-IFEQ .(shiftNameUp v a) .(shiftNameUp v a₁) .(shiftNameUp v a₂) .(shiftNameUp v a₃) upd₁ upd₂ upd₃ upd₄) = updCtxt2-IFEQ _ _ _ _ (updCtxt2-shiftNameUp→ v cf upd₁) (updCtxt2-shiftNameUp→ v cf upd₂) (updCtxt2-shiftNameUp→ v cf upd₃) (updCtxt2-shiftNameUp→ v cf upd₄)
updCtxt2-shiftNameUp→ v {name} {f} cf {SUC a} (updCtxt2-SUC .(shiftNameUp v a) upd₁) = updCtxt2-SUC _ (updCtxt2-shiftNameUp→ v cf upd₁)
updCtxt2-shiftNameUp→ v {name} {f} cf {NATREC a a₁ a₂} (updCtxt2-NATREC .(shiftNameUp v a) .(shiftNameUp v a₁) .(shiftNameUp v a₂) upd₁ upd₂ upd₃) = updCtxt2-NATREC _ _ _ (updCtxt2-shiftNameUp→ v cf upd₁) (updCtxt2-shiftNameUp→ v cf upd₂) (updCtxt2-shiftNameUp→ v cf upd₃)
updCtxt2-shiftNameUp→ v {name} {f} cf {PI a a₁} (updCtxt2-PI .(shiftNameUp v a) .(shiftNameUp v a₁) upd₁ upd₂) = updCtxt2-PI _ _ (updCtxt2-shiftNameUp→ v cf upd₁) (updCtxt2-shiftNameUp→ v cf upd₂)
updCtxt2-shiftNameUp→ v {name} {f} cf {LAMBDA a} upd =
updCtxt2-shiftNameUp-LAMBDA→ v {name} {f} cf {a} {shiftNameUp v a} refl upd ind
where
ind : updCtxt2 (sucIf≤ v name) (shiftNameUp v f) (shiftNameUp v a) → updCtxt2 name f a
ind = updCtxt2-shiftNameUp→ v cf
updCtxt2-shiftNameUp→ v {name} {f} cf {APPLY a a₁} (updCtxt2-APPLY .(shiftNameUp v a) .(shiftNameUp v a₁) upd₁ upd₂) = updCtxt2-APPLY _ _ (updCtxt2-shiftNameUp→ v cf upd₁) (updCtxt2-shiftNameUp→ v cf upd₂)
updCtxt2-shiftNameUp→ v {name} {f} cf {MSEQ s} (updCtxt2-MSEQ s) = updCtxt2-MSEQ s
updCtxt2-shiftNameUp→ v {name} {f} cf {MAPP s a} (updCtxt2-MAPP s .(shiftNameUp v a) upd₁) = updCtxt2-MAPP _ _ (updCtxt2-shiftNameUp→ v cf upd₁)
updCtxt2-shiftNameUp→ v {name} {f} cf {FIX a} (updCtxt2-FIX .(shiftNameUp v a) upd₁) = updCtxt2-FIX _ (updCtxt2-shiftNameUp→ v cf upd₁)
updCtxt2-shiftNameUp→ v {name} {f} cf {LET a a₁} (updCtxt2-LET .(shiftNameUp v a) .(shiftNameUp v a₁) upd₁ upd₂) = updCtxt2-LET _ _ (updCtxt2-shiftNameUp→ v cf upd₁) (updCtxt2-shiftNameUp→ v cf upd₂)
updCtxt2-shiftNameUp→ v {name} {f} cf {SUM a a₁} (updCtxt2-SUM .(shiftNameUp v a) .(shiftNameUp v a₁) upd₁ upd₂) = updCtxt2-SUM _ _ (updCtxt2-shiftNameUp→ v cf upd₁) (updCtxt2-shiftNameUp→ v cf upd₂)
updCtxt2-shiftNameUp→ v {name} {f} cf {PAIR a a₁} (updCtxt2-PAIR .(shiftNameUp v a) .(shiftNameUp v a₁) upd₁ upd₂) = updCtxt2-PAIR _ _ (updCtxt2-shiftNameUp→ v cf upd₁) (updCtxt2-shiftNameUp→ v cf upd₂)
updCtxt2-shiftNameUp→ v {name} {f} cf {SPREAD a a₁} (updCtxt2-SPREAD .(shiftNameUp v a) .(shiftNameUp v a₁) upd₁ upd₂) = updCtxt2-SPREAD _ _ (updCtxt2-shiftNameUp→ v cf upd₁) (updCtxt2-shiftNameUp→ v cf upd₂)
updCtxt2-shiftNameUp→ v {name} {f} cf {WT a a₁ a₂} (updCtxt2-WT .(shiftNameUp v a) .(shiftNameUp v a₁) .(shiftNameUp v a₂) upd₁ upd₂ upd₃) = updCtxt2-WT _ _ _ (updCtxt2-shiftNameUp→ v cf upd₁) (updCtxt2-shiftNameUp→ v cf upd₂) (updCtxt2-shiftNameUp→ v cf upd₃)
updCtxt2-shiftNameUp→ v {name} {f} cf {SUP a a₁} (updCtxt2-SUP .(shiftNameUp v a) .(shiftNameUp v a₁) upd₁ upd₂) = updCtxt2-SUP _ _ (updCtxt2-shiftNameUp→ v cf upd₁) (updCtxt2-shiftNameUp→ v cf upd₂)
updCtxt2-shiftNameUp→ v {name} {f} cf {WREC a a₁} (updCtxt2-WREC .(shiftNameUp v a) .(shiftNameUp v a₁) upd₁ upd₂) = updCtxt2-WREC _ _ (updCtxt2-shiftNameUp→ v cf upd₁) (updCtxt2-shiftNameUp→ v cf upd₂)
updCtxt2-shiftNameUp→ v {name} {f} cf {MT a a₁ a₂} (updCtxt2-MT .(shiftNameUp v a) .(shiftNameUp v a₁) .(shiftNameUp v a₂) upd₁ upd₂ upd₃) = updCtxt2-MT _ _ _ (updCtxt2-shiftNameUp→ v cf upd₁) (updCtxt2-shiftNameUp→ v cf upd₂) (updCtxt2-shiftNameUp→ v cf upd₃)
updCtxt2-shiftNameUp→ v {name} {f} cf {SET a a₁} (updCtxt2-SET .(shiftNameUp v a) .(shiftNameUp v a₁) upd₁ upd₂) = updCtxt2-SET _ _ (updCtxt2-shiftNameUp→ v cf upd₁) (updCtxt2-shiftNameUp→ v cf upd₂)
updCtxt2-shiftNameUp→ v {name} {f} cf {TUNION a a₁} (updCtxt2-TUNION .(shiftNameUp v a) .(shiftNameUp v a₁) upd₁ upd₂) = updCtxt2-TUNION _ _ (updCtxt2-shiftNameUp→ v cf upd₁) (updCtxt2-shiftNameUp→ v cf upd₂)
updCtxt2-shiftNameUp→ v {name} {f} cf {ISECT a a₁} (updCtxt2-ISECT .(shiftNameUp v a) .(shiftNameUp v a₁) upd₁ upd₂) = updCtxt2-ISECT _ _ (updCtxt2-shiftNameUp→ v cf upd₁) (updCtxt2-shiftNameUp→ v cf upd₂)
updCtxt2-shiftNameUp→ v {name} {f} cf {UNION a a₁} (updCtxt2-UNION .(shiftNameUp v a) .(shiftNameUp v a₁) upd₁ upd₂) = updCtxt2-UNION _ _ (updCtxt2-shiftNameUp→ v cf upd₁) (updCtxt2-shiftNameUp→ v cf upd₂)
-- updCtxt2-shiftNameUp→ v {name} {f} cf {QTUNION a a₁} (updCtxt2-QTUNION .(shiftNameUp v a) .(shiftNameUp v a₁) upd₁ upd₂) = updCtxt2-QTUNION _ _ (updCtxt2-shiftNameUp→ v cf upd₁) (updCtxt2-shiftNameUp→ v cf upd₂)
updCtxt2-shiftNameUp→ v {name} {f} cf {INL a} (updCtxt2-INL .(shiftNameUp v a) upd₁) = updCtxt2-INL _ (updCtxt2-shiftNameUp→ v cf upd₁)
updCtxt2-shiftNameUp→ v {name} {f} cf {INR a} (updCtxt2-INR .(shiftNameUp v a) upd₁) = updCtxt2-INR _ (updCtxt2-shiftNameUp→ v cf upd₁)
updCtxt2-shiftNameUp→ v {name} {f} cf {DECIDE a a₁ a₂} (updCtxt2-DECIDE .(shiftNameUp v a) .(shiftNameUp v a₁) .(shiftNameUp v a₂) upd₁ upd₂ upd₃) = updCtxt2-DECIDE _ _ _ (updCtxt2-shiftNameUp→ v cf upd₁) (updCtxt2-shiftNameUp→ v cf upd₂) (updCtxt2-shiftNameUp→ v cf upd₃)
updCtxt2-shiftNameUp→ v {name} {f} cf {EQ a a₁ a₂} (updCtxt2-EQ .(shiftNameUp v a) .(shiftNameUp v a₁) .(shiftNameUp v a₂) upd₁ upd₂ upd₃) = updCtxt2-EQ _ _ _ (updCtxt2-shiftNameUp→ v cf upd₁) (updCtxt2-shiftNameUp→ v cf upd₂) (updCtxt2-shiftNameUp→ v cf upd₃)
-- updCtxt2-shiftNameUp→ v {name} {f} cf {EQB a a₁ a₂ a₃} (updCtxt2-EQB .(shiftNameUp v a) .(shiftNameUp v a₁) .(shiftNameUp v a₂) .(shiftNameUp v a₃) upd₁ upd₂ upd₃ upd₄) = updCtxt2-EQB _ _ _ _ (updCtxt2-shiftNameUp→ v cf upd₁) (updCtxt2-shiftNameUp→ v cf upd₂) (updCtxt2-shiftNameUp→ v cf upd₃) (updCtxt2-shiftNameUp→ v cf upd₄)
updCtxt2-shiftNameUp→ v {name} {f} cf {AX} upd = updCtxt2-AX
updCtxt2-shiftNameUp→ v {name} {f} cf {FREE} upd = updCtxt2-FREE
updCtxt2-shiftNameUp→ v {name} {f} cf {CS x} upd = updCtxt2-CS _
updCtxt2-shiftNameUp→ v {name} {f} cf {NAME x} (updCtxt2-NAME .(sucIf≤ v x) d) = updCtxt2-NAME _ λ z → d (→≡sucIf≤ z)
updCtxt2-shiftNameUp→ v {name} {f} cf {FRESH a} (updCtxt2-FRESH .(shiftNameUp (suc v) a) upd₁) =
updCtxt2-FRESH a (updCtxt2-shiftNameUp→ (suc v) {suc name} {shiftNameUp 0 f} (→#shiftNameUp 0 {f} cf) upd1)
where
seq : suc (sucIf≤ v name) ≡ sucIf≤ (suc v) (sucIf≤ 0 name)
seq rewrite sym (sucIf≤-sucIf≤ {name} {0} {v} _≤_.z≤n) | sym (suc≡sucIf≤0 (sucIf≤ v name)) = refl
upd1 : updCtxt2 (sucIf≤ (suc v) (suc name)) (shiftNameUp (suc v) (shiftNameUp 0 f)) (shiftNameUp (suc v) a)
upd1 rewrite suc≡sucIf≤0 name | sym seq | sym (shiftNameUp-shiftNameUp {0} {v} {f} _≤_.z≤n) = upd₁
updCtxt2-shiftNameUp→ v {name} {f} cf {LOAD a} (updCtxt2-LOAD .a) = updCtxt2-LOAD _ --(updCtxt2-shiftNameUp→ v cf upd₁)
updCtxt2-shiftNameUp→ v {name} {f} cf {CHOOSE a a₁} (updCtxt2-CHOOSE .(shiftNameUp v a) .(shiftNameUp v a₁) upd₁ upd₂) = updCtxt2-CHOOSE _ _ (updCtxt2-shiftNameUp→ v cf upd₁) (updCtxt2-shiftNameUp→ v cf upd₂)
-- updCtxt2-shiftNameUp→ v {name} {f} cf {TSQUASH a} (updCtxt2-TSQUASH .(shiftNameUp v a) upd₁) = updCtxt2-TSQUASH _ (updCtxt2-shiftNameUp→ v cf upd₁)
-- updCtxt2-shiftNameUp→ v {name} {f} cf {TTRUNC a} (updCtxt2-TTRUNC .(shiftNameUp v a) upd₁) = updCtxt2-TTRUNC _ (updCtxt2-shiftNameUp→ v cf upd₁)
updCtxt2-shiftNameUp→ v {name} {f} cf {NOWRITE} updCtxt2-NOWRITE = updCtxt2-NOWRITE
updCtxt2-shiftNameUp→ v {name} {f} cf {NOREAD} updCtxt2-NOREAD = updCtxt2-NOREAD
updCtxt2-shiftNameUp→ v {name} {f} cf {SUBSING a} (updCtxt2-SUBSING .(shiftNameUp v a) upd₁) = updCtxt2-SUBSING _ (updCtxt2-shiftNameUp→ v cf upd₁)
updCtxt2-shiftNameUp→ v {name} {f} cf {PARTIAL a} (updCtxt2-PARTIAL .(shiftNameUp v a) upd₁) = updCtxt2-PARTIAL _ (updCtxt2-shiftNameUp→ v cf upd₁)
updCtxt2-shiftNameUp→ v {name} {f} cf {FFDEFS a a₁} (updCtxt2-FFDEFS .(shiftNameUp v a) .(shiftNameUp v a₁) upd₁ upd₂) = updCtxt2-FFDEFS _ _ (updCtxt2-shiftNameUp→ v cf upd₁) (updCtxt2-shiftNameUp→ v cf upd₂)
updCtxt2-shiftNameUp→ v {name} {f} cf {PURE} upd = updCtxt2-PURE
updCtxt2-shiftNameUp→ v {name} {f} cf {NOSEQ} upd = updCtxt2-NOSEQ
updCtxt2-shiftNameUp→ v {name} {f} cf {NOENC} upd = updCtxt2-NOENC
updCtxt2-shiftNameUp→ v {name} {f} cf {TERM a} (updCtxt2-TERM .(shiftNameUp v a) upd₁) = updCtxt2-TERM _ (updCtxt2-shiftNameUp→ v cf upd₁)
updCtxt2-shiftNameUp→ v {name} {f} cf {ENC a} (updCtxt2-ENC .(shiftNameUp v a) upd₁) = updCtxt2-ENC _ (updCtxt2-shiftNameUp→ v cf upd₁)
updCtxt2-shiftNameUp→ v {name} {f} cf {UNIV x} upd = updCtxt2-UNIV _
updCtxt2-shiftNameUp→ v {name} {f} cf {LIFT a} (updCtxt2-LIFT .(shiftNameUp v a) upd₁) = updCtxt2-LIFT _ (updCtxt2-shiftNameUp→ v cf upd₁)
updCtxt2-shiftNameUp→ v {name} {f} cf {LOWER a} (updCtxt2-LOWER .(shiftNameUp v a) upd₁) = updCtxt2-LOWER _ (updCtxt2-shiftNameUp→ v cf upd₁)
updCtxt2-shiftNameUp→ v {name} {f} cf {SHRINK a} (updCtxt2-SHRINK .(shiftNameUp v a) upd₁) = updCtxt2-SHRINK _ (updCtxt2-shiftNameUp→ v cf upd₁)
¬∈names→isHighestℕ-step : (cc : ContConds) {t u : Term} {w1 w2 : 𝕎·} {n : ℕ} {name : Name}
→ ¬ name ∈ names t
→ ¬ name ∈ names𝕎· w1
→ name ∈ dom𝕎· w1
→ getT≤ℕ w1 n name
→ step t w1 ≡ just (u , w2)
→ ¬ name ∈ names u
× ¬ name ∈ names𝕎· w2
× name ∈ dom𝕎· w2
× getT≤ℕ w2 n name
¬∈names→isHighestℕ-step cc {t} {u} {w1} {w2} {n} {name} nnt nnw idom gt comp =
fst (snd h) , fst (snd (snd h)) , snd (snd (snd h)) , gt2
where
h : getT 0 name w1 ≡ getT 0 name w2 × ¬ name ∈ names u × ¬ name ∈ names𝕎· w2 × name ∈ dom𝕎· w2
h = name¬∈→step cc w1 w2 t u name comp nnt nnw idom
gt2 : getT≤ℕ w2 n name
gt2 rewrite (sym (fst h)) = gt
¬∈names→isHighestℕ : (cc : ContConds) {k : ℕ} {t u : Term} {w1 w2 : 𝕎·} {n : ℕ} {name : Name}
→ ¬ name ∈ names t
→ ¬ name ∈ names𝕎· w1
→ name ∈ dom𝕎· w1
→ getT≤ℕ w1 n name
→ (comp : steps k (t , w1) ≡ (u , w2))
→ isHighestℕ {k} {w1} {w2} n name comp
¬∈names→isHighestℕ cc {0} {t} {u} {w1} {w2} {n} {name} nnt nnw idom gtn comp
rewrite sym (pair-inj₁ comp) | sym (pair-inj₂ comp) = gtn
¬∈names→isHighestℕ cc {suc k} {t} {u} {w1} {w2} {n} {name} nnt nnw idom gtn comp with step⊎ t w1
... | inj₁ (t' , w1' , z) rewrite z =
gtn , ¬∈names→isHighestℕ cc {k} {t'} {u} {w1'} {w2} {n} {name} (fst q) (fst (snd q)) (fst (snd (snd q))) (snd (snd (snd q))) comp
where
q : ¬ name ∈ names t' × ¬ name ∈ names𝕎· w1' × name ∈ dom𝕎· w1' × getT≤ℕ w1' n name
q = ¬∈names→isHighestℕ-step cc {t} {t'} {w1} {w1'} {n} {name} nnt nnw idom gtn z
... | inj₂ z rewrite z | sym (pair-inj₁ comp) | sym (pair-inj₂ comp) = gtn
¬∈names→∈names𝕎 : (cc : ContConds) {k : ℕ} {t u : Term} {w1 w2 : 𝕎·} {name : Name}
→ ¬ name ∈ names t
→ ¬ name ∈ names𝕎· w1
→ name ∈ dom𝕎· w1
→ (comp : steps k (t , w1) ≡ (u , w2))
→ ∈names𝕎 {k} {w1} {w2} name comp
¬∈names→∈names𝕎 cc {0} {t} {u} {w1} {w2} {name} nnt nnw idom comp
rewrite sym (pair-inj₁ comp) | sym (pair-inj₂ comp) = nnw , idom
¬∈names→∈names𝕎 cc {suc k} {t} {u} {w1} {w2} {name} nnt nnw idom comp with step⊎ t w1
... | inj₁ (t' , w1' , z) rewrite z =
nnw , idom ,
¬∈names→∈names𝕎 cc {k} {t'} {u} {w1'} {w2} {name} (fst (snd q)) (fst (snd (snd q))) (snd (snd (snd q))) comp
where
q : getT 0 name w1 ≡ getT 0 name w1' × ¬ name ∈ names t' × ¬ name ∈ names𝕎· w1' × name ∈ dom𝕎· w1'
q = name¬∈→step cc w1 w1' t t' name z nnt nnw idom
... | inj₂ z rewrite z | sym (pair-inj₁ comp) | sym (pair-inj₂ comp) = nnw , idom
→isHighestℕ-upd-body2-NUM3b :
(cc : ContConds) (gc : get-choose-ℕ) {k : ℕ} {name : Name} {w : 𝕎·} {f : Term} {n m m' : ℕ}
→ # f
→ ¬ name ∈ names f
→ ¬ name ∈ names𝕎· w
→ name ∈ dom𝕎· w
→ compatible· name w Res⊤
→ (comp : steps k (LET AX (APPLY (shiftDown 1 (subv 1 (NUM m) (shiftUp 0 f))) (NUM m)) , chooseT name w (NUM m))
≡ (APPLY f (NUM m) , chooseT name w (NUM m)))
→ getT 0 name w ≡ just (NUM m')
→ m < n
→ isHighestℕ {k} {chooseT name w (NUM m)} {chooseT name w (NUM m)} n name comp
→isHighestℕ-upd-body2-NUM3b cc gc {0} {name} {w} {f} {n} {m} {m'} cf nnf nnw idom compat () g0 ltn
→isHighestℕ-upd-body2-NUM3b cc gc {suc k} {name} {w} {f} {n} {m} {m'} cf nnf nnw idom compat comp g0 ltn
rewrite #shiftUp 0 (ct f cf) | subv# 1 (NUM m) f cf | #shiftUp 0 (ct f cf) | #shiftDown 1 (ct f cf)
| #shiftUp 0 (ct f cf) | subv# 0 AX f cf | #shiftDown 0 (ct f cf) =
g1 ,
¬∈names→isHighestℕ
cc {k} {APPLY f (NUM m)} {APPLY f (NUM m)} {chooseT name w (NUM m)} {chooseT name w (NUM m)} {n} {name}
(¬∈names-APPLY {name} {f} {NUM m} nnf (¬∈names-NUM {name} {m}))
(λ z → nnw (names𝕎-chooseT→ cc name name w (NUM m) z))
(dom𝕎-chooseT cc name name w (NUM m) idom)
g1 comp
where
g1 : getT≤ℕ (chooseT name w (NUM m)) n name
g1 rewrite gc name w m compat = m , refl , ltn
→isHighestℕ-upd-body2-NUM3b-∈names𝕎 :
(cc : ContConds) (gc : get-choose-ℕ) {k : ℕ} {name : Name} {w : 𝕎·} {f : Term} {m m' : ℕ}
→ # f
→ ¬ name ∈ names f
→ ¬ name ∈ names𝕎· w
→ name ∈ dom𝕎· w
→ (comp : steps k (LET AX (APPLY (shiftDown 1 (subv 1 (NUM m) (shiftUp 0 f))) (NUM m)) , chooseT name w (NUM m))
≡ (APPLY f (NUM m) , chooseT name w (NUM m)))
→ ∈names𝕎 {k} {chooseT name w (NUM m)} {chooseT name w (NUM m)} name comp
→isHighestℕ-upd-body2-NUM3b-∈names𝕎 cc gc {0} {name} {w} {f} {m} {m'} cf nnf nnw idom comp =
(λ z → nnw (names𝕎-chooseT→ cc name name w (NUM m) z)) ,
dom𝕎-chooseT cc name name w (NUM m) idom
→isHighestℕ-upd-body2-NUM3b-∈names𝕎 cc gc {suc k} {name} {w} {f} {m} {m'} cf nnf nnw idom comp
rewrite #shiftUp 0 (ct f cf) | subv# 1 (NUM m) f cf | #shiftUp 0 (ct f cf) | #shiftDown 1 (ct f cf)
| #shiftUp 0 (ct f cf) | subv# 0 AX f cf | #shiftDown 0 (ct f cf) =
(λ z → nnw (names𝕎-chooseT→ cc name name w (NUM m) z)) ,
dom𝕎-chooseT cc name name w (NUM m) idom ,
¬∈names→∈names𝕎
cc {k} {APPLY f (NUM m)} {APPLY f (NUM m)} {chooseT name w (NUM m)} {chooseT name w (NUM m)} {name}
(¬∈names-APPLY {name} {f} {NUM m} nnf (¬∈names-NUM {name} {m}))
(λ z → nnw (names𝕎-chooseT→ cc name name w (NUM m) z))
(dom𝕎-chooseT cc name name w (NUM m) idom)
comp
→isHighestℕ-upd-body2-NUM3 :
(cc : ContConds) (gc : get-choose-ℕ) {k : ℕ} {name : Name} {w : 𝕎·} {f : Term} {n m m' : ℕ}
→ # f
→ ¬ name ∈ names f
→ ¬ name ∈ names𝕎· w
→ name ∈ dom𝕎· w
→ compatible· name w Res⊤
→ (comp : steps k (LET (CHOOSE (NAME name) (NUM m)) (APPLY (shiftDown 1 (subv 1 (NUM m) (shiftUp 0 f))) (NUM m)) , w)
≡ (APPLY f (NUM m) , chooseT name w (NUM m)))
→ getT 0 name w ≡ just (NUM m')
→ m' < n
→ m < n
→ isHighestℕ {k} {w} {chooseT name w (NUM m)} n name comp
→isHighestℕ-upd-body2-NUM3 cc gc {0} {name} {w} {f} {n} {m} {m'} cf nnf nnw idom compat () g0 ltn ltn'
→isHighestℕ-upd-body2-NUM3 cc gc {suc k} {name} {w} {f} {n} {m} {m'} cf nnf nnw idom compat comp g0 ltn ltn' =
(m' , g0 , ltn) ,
→isHighestℕ-upd-body2-NUM3b cc gc {k} {name} {w} {f} {n} {m} {m'} cf nnf nnw idom compat comp g0 ltn'
→isHighestℕ-upd-body2-NUM3-∈names𝕎 :
(cc : ContConds) (gc : get-choose-ℕ) {k : ℕ} {name : Name} {w : 𝕎·} {f : Term} {m m' : ℕ}
→ # f
→ ¬ name ∈ names f
→ ¬ name ∈ names𝕎· w
→ name ∈ dom𝕎· w
→ (comp : steps k (LET (CHOOSE (NAME name) (NUM m)) (APPLY (shiftDown 1 (subv 1 (NUM m) (shiftUp 0 f))) (NUM m)) , w)
≡ (APPLY f (NUM m) , chooseT name w (NUM m)))
→ ∈names𝕎 {k} {w} {chooseT name w (NUM m)} name comp
→isHighestℕ-upd-body2-NUM3-∈names𝕎 cc gc {0} {name} {w} {f} {m} {m'} cf nnf nnw idom ()
→isHighestℕ-upd-body2-NUM3-∈names𝕎 cc gc {suc k} {name} {w} {f} {m} {m'} cf nnf nnw idom comp =
nnw , idom ,
→isHighestℕ-upd-body2-NUM3b-∈names𝕎 cc gc {k} {name} {w} {f} {m} {m'} cf nnf nnw idom comp
→isHighestℕ-upd-body2-NUM4 :
(cc : ContConds) {k : ℕ} {name : Name} {w : 𝕎·} {f : Term} {n m m' : ℕ}
→ # f
→ ¬ name ∈ names f
→ ¬ name ∈ names𝕎· w
→ name ∈ dom𝕎· w
→ (comp : steps k (LET AX (APPLY (shiftDown 1 (subv 1 (NUM m) (shiftUp 0 f))) (NUM m)) , w)
≡ (APPLY f (NUM m) , w))
→ getT 0 name w ≡ just (NUM m')
→ m' < n
→ isHighestℕ {k} {w} {w} n name comp
→isHighestℕ-upd-body2-NUM4 cc {0} {name} {w} {f} {n} {m} {m'} cf nnf nnw idom () g0 ltn
→isHighestℕ-upd-body2-NUM4 cc {suc k} {name} {w} {f} {n} {m} {m'} cf nnf nnw idom comp g0 ltn
rewrite #shiftUp 0 (ct f cf) | subv# 1 (NUM m) f cf | #shiftDown 1 (ct f cf)
| #shiftUp 0 (ct f cf) | subv# 0 AX f cf | #shiftDown 0 (ct f cf) =
(m' , g0 , ltn) ,
¬∈names→isHighestℕ cc {k} {APPLY f (NUM m)} {APPLY f (NUM m)} {w} {w} {n} {name} (¬∈names-APPLY {name} {f} {NUM m} nnf (¬∈names-NUM {name} {m})) nnw idom (m' , g0 , ltn) comp
→isHighestℕ-upd-body2-NUM4-∈names𝕎 :
(cc : ContConds) {k : ℕ} {name : Name} {w : 𝕎·} {f : Term} {m m' : ℕ}
→ # f
→ ¬ name ∈ names f
→ ¬ name ∈ names𝕎· w
→ name ∈ dom𝕎· w
→ (comp : steps k (LET AX (APPLY (shiftDown 1 (subv 1 (NUM m) (shiftUp 0 f))) (NUM m)) , w)
≡ (APPLY f (NUM m) , w))
→ ∈names𝕎 {k} {w} {w} name comp
→isHighestℕ-upd-body2-NUM4-∈names𝕎 cc {0} {name} {w} {f} {m} {m'} cf nnf nnw idom ()
→isHighestℕ-upd-body2-NUM4-∈names𝕎 cc {suc k} {name} {w} {f} {m} {m'} cf nnf nnw idom comp
rewrite #shiftUp 0 (ct f cf) | subv# 1 (NUM m) f cf | #shiftDown 1 (ct f cf)
| #shiftUp 0 (ct f cf) | subv# 0 AX f cf | #shiftDown 0 (ct f cf) =
nnw , idom ,
¬∈names→∈names𝕎
cc {k} {APPLY f (NUM m)} {APPLY f (NUM m)} {w} {w} {name}
(¬∈names-APPLY {name} {f} {NUM m} nnf (¬∈names-NUM {name} {m}))
nnw idom comp
→isHighestℕ-upd-body2-NUM2 :
(cc : ContConds) (gc : get-choose-ℕ) {k : ℕ} {name : Name} {w : 𝕎·} {f : Term} {n m m' : ℕ}
→ # f
→ ¬ name ∈ names f
→ ¬ name ∈ names𝕎· w
→ name ∈ dom𝕎· w
→ compatible· name w Res⊤
→ (comp : steps k (LET (IFLT (NUM m') (NUM m) (setT name (NUM m)) AX) (APPLY (shiftDown 1 (subv 1 (NUM m) (shiftUp 0 f))) (NUM m)) , w)
≡ (APPLY f (NUM m) , chooseT0if name w m' m))
→ getT 0 name w ≡ just (NUM m')
→ m' < n
→ getT≤ℕ (chooseT0if name w m' m) n name
→ isHighestℕ {k} {w} {chooseT0if name w m' m} n name comp
→isHighestℕ-upd-body2-NUM2 cc gc {0} {name} {w} {f} {n} {m} {m'} cf nnf nnw idom compat () g0 ltn gtn
→isHighestℕ-upd-body2-NUM2 cc gc {suc k} {name} {w} {f} {n} {m} {m'} cf nnf nnw idom compat comp g0 ltn gtn with m' <? m
... | yes x = (m' , g0 , ltn) , →isHighestℕ-upd-body2-NUM3 cc gc {k} {name} {w} {f} {n} {m} {m'} cf nnf nnw idom compat comp g0 ltn (getT≤ℕ-chooseT→ gc {name} {w} {n} {m} compat gtn)
... | no x = (m' , g0 , ltn) , →isHighestℕ-upd-body2-NUM4 cc {k} {name} {w} {f} {n} {m} {m'} cf nnf nnw idom comp g0 ltn
→isHighestℕ-upd-body2-NUM2-∈names𝕎 :
(cc : ContConds) (gc : get-choose-ℕ) {k : ℕ} {name : Name} {w : 𝕎·} {f : Term} {m m' : ℕ}
→ # f
→ ¬ name ∈ names f
→ ¬ name ∈ names𝕎· w
→ name ∈ dom𝕎· w