-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathSupportedSpec.lean
More file actions
4335 lines (4064 loc) · 211 KB
/
SupportedSpec.lean
File metadata and controls
4335 lines (4064 loc) · 211 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import Compiler.Proofs.IRGeneration.SupportedFragment
import Compiler.CompilationModel.AbiHelpers
import Compiler.CompilationModel.Dispatch
import Compiler.CompilationModel.UsageAnalysis
import Compiler.CompilationModel.SelectorInteropHelpers
import Compiler.TypedIRCompilerCorrectness
namespace Compiler.Proofs.IRGeneration
open Compiler
open Compiler.CompilationModel
/-- ABI parameter types admitted by the first whole-contract Layer 2 fragment.
Only single-head-word scalars are included for the initial generic theorem. -/
def SupportedExternalParamType : ParamType → Prop
| .uint256 | .int256 | .uint8 | .address | .bytes32 => True
| _ => False
/-- Return profiles admitted by the first whole-contract Layer 2 fragment.
The initial theorem only targets zero-return or single-head-word-return entrypoints. -/
def SupportedExternalReturnProfile : List ParamType → Prop
| [] => True
| [ty] => SupportedExternalParamType ty
| _ => False
/-- Selector-dispatched entrypoints in the same order used by `CompilationModel.compile`. -/
def selectorDispatchedFunctions (spec : CompilationModel) : List FunctionSpec :=
spec.functions.filter (fun fn => !fn.isInternal && !isInteropEntrypointName fn.name)
/-- Parameter-profile interface for selector-dispatched entrypoints covered by the
current whole-contract theorem. -/
structure SupportedParamProfile (params : List Param) : Prop where
namesNodup : (params.map (·.name)).Nodup
supported : ∀ param ∈ params, SupportedExternalParamType param.ty
/-- Return-profile interface for selector-dispatched entrypoints covered by the
current whole-contract theorem. -/
structure SupportedReturnProfile (fn : FunctionSpec) : Prop where
resolved :
∃ resolvedReturns,
functionReturns fn = Except.ok resolvedReturns ∧
SupportedExternalReturnProfile resolvedReturns
/-- Pure expression forms still outside the current generic-induction core, even
before any richer contract surface is considered. This tracks proof-core gaps
rather than a semantic trust boundary. -/
def exprTouchesUnsupportedCoreSurface : Expr → Bool
| .literal _ | .param _ | .caller | .contractAddress
| .chainid | .msgValue | .blockTimestamp | .blockNumber
| .localVar _ => false
| .storage _ | .storageAddr _ => false
| .add a b | .sub a b | .mul a b | .div a b | .mod a b
| .eq a b | .ge a b | .gt a b | .lt a b | .le a b
| .logicalAnd a b | .logicalOr a b =>
exprTouchesUnsupportedCoreSurface a || exprTouchesUnsupportedCoreSurface b
| .logicalNot a => exprTouchesUnsupportedCoreSurface a
| .sdiv a b | .smod a b | .bitAnd a b | .bitOr a b | .bitXor a b
| .sgt a b | .slt a b | .min a b | .max a b | .wMulDown a b | .wDivUp a b
| .ceilDiv a b =>
true
| .bitNot _ => true
| .ite _ _ _ => true
| .mulDivDown _ _ _ | .mulDivUp _ _ _ | .shl _ _
| .shr _ _ | .sar _ _ | .signextend _ _ => true
| .mapping _ _ | .mappingWord _ _ _ | .mappingPackedWord _ _ _ _
| .mapping2 _ _ _ | .mapping2Word _ _ _ _ | .mappingUint _ _ | .mappingChain _ _
| .structMember _ _ _ | .structMember2 _ _ _ _
| .constructorArg _ | .blobbasefee | .mload _ | .tload _ | .keccak256 _ _
| .call _ _ _ _ _ _ _ | .staticcall _ _ _ _ _ _ | .delegatecall _ _ _ _ _ _
| .calldatasize | .calldataload _ | .returndataSize | .extcodesize _
| .returndataOptionalBoolAt _ | .externalCall _ _ | .internalCall _ _
| .arrayLength _ | .arrayElement _ _ | .storageArrayLength _ | .storageArrayElement _ _
| .dynamicBytesEq _ _ => true
/-- Stateful expression surfaces not yet carried by the generic Layer 2 body
interface. These are the next storage/layout-style widening targets. -/
def exprTouchesUnsupportedStateSurface : Expr → Bool
| .literal _ | .param _ | .caller | .contractAddress
| .chainid | .msgValue | .blockTimestamp | .blockNumber
| .localVar _ => false
| .storage _ | .storageAddr _ => true
| .mapping _ _ | .mappingWord _ _ _ | .mappingPackedWord _ _ _ _
| .mapping2 _ _ _ | .mapping2Word _ _ _ _ | .mappingUint _ _ | .mappingChain _ _
| .structMember _ _ _ | .structMember2 _ _ _ _
| .storageArrayLength _ | .storageArrayElement _ _ => true
| .add a b | .sub a b | .mul a b | .div a b | .sdiv a b | .mod a b | .smod a b
| .bitAnd a b | .bitOr a b | .bitXor a b | .eq a b
| .ge a b | .gt a b | .sgt a b | .lt a b | .slt a b | .le a b
| .logicalAnd a b | .logicalOr a b =>
exprTouchesUnsupportedStateSurface a || exprTouchesUnsupportedStateSurface b
| .min a b | .max a b | .wMulDown a b | .wDivUp a b | .ceilDiv a b =>
exprTouchesUnsupportedStateSurface a || exprTouchesUnsupportedStateSurface b
| .bitNot a | .logicalNot a => exprTouchesUnsupportedStateSurface a
| .ite cond thenVal elseVal =>
exprTouchesUnsupportedStateSurface cond ||
exprTouchesUnsupportedStateSurface thenVal ||
exprTouchesUnsupportedStateSurface elseVal
| .constructorArg _ | .blobbasefee | .mload _ | .tload _ | .keccak256 _ _
| .call _ _ _ _ _ _ _ | .staticcall _ _ _ _ _ _ | .delegatecall _ _ _ _ _ _
| .calldatasize | .calldataload _ | .returndataSize | .extcodesize _
| .returndataOptionalBoolAt _ | .externalCall _ _ | .internalCall _ _
| .arrayLength _ | .arrayElement _ _ | .mulDivDown _ _ _ | .mulDivUp _ _ _
| .shl _ _ | .shr _ _ | .sar _ _ | .signextend _ _
| .dynamicBytesEq _ _ => false
/-- Call-related surfaces that still sit outside the current generic Layer 2
body theorem: internal helper reuse, low-level calls, and foreign call hooks. -/
def exprTouchesUnsupportedCallSurface : Expr → Bool
| .internalCall _ _ | .externalCall _ _ => true
| .call _ _ _ _ _ _ _ | .staticcall _ _ _ _ _ _ | .delegatecall _ _ _ _ _ _ => true
| .literal _ | .param _ | .caller | .contractAddress
| .chainid | .msgValue | .blockTimestamp | .blockNumber
| .localVar _ | .storage _ | .storageAddr _
| .constructorArg _ | .blobbasefee | .mload _ | .tload _
| .calldatasize | .calldataload _ | .returndataSize | .extcodesize _
| .returndataOptionalBoolAt _ | .keccak256 _ _ | .arrayLength _
| .storageArrayLength _ => false
| .add a b | .sub a b | .mul a b | .div a b | .sdiv a b | .mod a b | .smod a b
| .bitAnd a b | .bitOr a b | .bitXor a b | .eq a b
| .ge a b | .gt a b | .sgt a b | .lt a b | .slt a b | .le a b
| .logicalAnd a b | .logicalOr a b =>
exprTouchesUnsupportedCallSurface a || exprTouchesUnsupportedCallSurface b
| .min a b | .max a b | .wMulDown a b | .wDivUp a b | .ceilDiv a b =>
exprTouchesUnsupportedCallSurface a || exprTouchesUnsupportedCallSurface b
| .mapping _ b | .mappingUint _ b | .arrayElement _ b | .storageArrayElement _ b =>
exprTouchesUnsupportedCallSurface b
| .mappingChain _ _ => true
| .bitNot a | .logicalNot a | .mappingWord _ a _ | .mappingPackedWord _ a _ _
| .structMember _ a _ => exprTouchesUnsupportedCallSurface a
| .ite cond thenVal elseVal =>
exprTouchesUnsupportedCallSurface cond ||
exprTouchesUnsupportedCallSurface thenVal ||
exprTouchesUnsupportedCallSurface elseVal
| .mapping2 _ a b | .mapping2Word _ a b _ | .structMember2 _ a b _ =>
exprTouchesUnsupportedCallSurface a || exprTouchesUnsupportedCallSurface b
| .mulDivDown a b c | .mulDivUp a b c =>
exprTouchesUnsupportedCallSurface a ||
exprTouchesUnsupportedCallSurface b ||
exprTouchesUnsupportedCallSurface c
| .shl a b | .shr a b | .sar a b | .signextend a b =>
exprTouchesUnsupportedCallSurface a || exprTouchesUnsupportedCallSurface b
| .dynamicBytesEq _ _ => false
/-- Internal helper-call surfaces not yet modeled compositionally in the current
generic whole-contract theorem. -/
def exprTouchesUnsupportedHelperSurface : Expr → Bool
| .internalCall _ _ => true
| .literal _ | .param _ | .caller | .contractAddress
| .chainid | .msgValue | .blockTimestamp | .blockNumber
| .localVar _ | .storage _ | .storageAddr _
| .constructorArg _ | .blobbasefee | .mload _ | .tload _
| .calldatasize | .calldataload _ | .returndataSize | .extcodesize _
| .returndataOptionalBoolAt _ | .keccak256 _ _ | .arrayLength _
| .storageArrayLength _ | .externalCall _ _ => false
| .call _ _ _ _ _ _ _ | .staticcall _ _ _ _ _ _ | .delegatecall _ _ _ _ _ _ => false
| .add a b | .sub a b | .mul a b | .div a b | .sdiv a b | .mod a b | .smod a b
| .bitAnd a b | .bitOr a b | .bitXor a b | .eq a b
| .ge a b | .gt a b | .sgt a b | .lt a b | .slt a b | .le a b
| .logicalAnd a b | .logicalOr a b =>
exprTouchesUnsupportedHelperSurface a || exprTouchesUnsupportedHelperSurface b
| .min a b | .max a b | .wMulDown a b | .wDivUp a b | .ceilDiv a b =>
exprTouchesUnsupportedHelperSurface a || exprTouchesUnsupportedHelperSurface b
| .mapping _ b | .mappingUint _ b | .arrayElement _ b | .storageArrayElement _ b =>
exprTouchesUnsupportedHelperSurface b
| .mappingChain _ _ => true
| .bitNot a | .logicalNot a | .mappingWord _ a _ | .mappingPackedWord _ a _ _
| .structMember _ a _ => exprTouchesUnsupportedHelperSurface a
| .ite cond thenVal elseVal =>
exprTouchesUnsupportedHelperSurface cond ||
exprTouchesUnsupportedHelperSurface thenVal ||
exprTouchesUnsupportedHelperSurface elseVal
| .mapping2 _ a b | .mapping2Word _ a b _ | .structMember2 _ a b _ =>
exprTouchesUnsupportedHelperSurface a || exprTouchesUnsupportedHelperSurface b
| .mulDivDown a b c | .mulDivUp a b c =>
exprTouchesUnsupportedHelperSurface a ||
exprTouchesUnsupportedHelperSurface b ||
exprTouchesUnsupportedHelperSurface c
| .shl a b | .shr a b | .sar a b | .signextend a b =>
exprTouchesUnsupportedHelperSurface a || exprTouchesUnsupportedHelperSurface b
| .dynamicBytesEq _ _ => false
def exprListTouchesUnsupportedHelperSurface : List Expr → Bool
| [] => false
| expr :: rest =>
exprTouchesUnsupportedHelperSurface expr ||
exprListTouchesUnsupportedHelperSurface rest
/-- Narrow helper-effect surface used by the exact helper-aware induction seam:
this tracks only genuine internal-helper execution, not the broader set of
still-unsupported expression shapes that currently share the coarse
`exprTouchesUnsupportedHelperSurface` approximation. -/
def exprTouchesInternalHelperSurface : Expr → Bool
| .internalCall _ _ => true
| .literal _ | .param _ | .caller | .contractAddress
| .chainid | .msgValue | .blockTimestamp | .blockNumber
| .localVar _ | .storage _ | .storageAddr _
| .constructorArg _ | .blobbasefee | .mload _ | .tload _
| .calldatasize | .calldataload _ | .returndataSize | .extcodesize _
| .returndataOptionalBoolAt _ | .keccak256 _ _ | .arrayLength _
| .storageArrayLength _ | .externalCall _ _ => false
| .call _ _ _ _ _ _ _ | .staticcall _ _ _ _ _ _ | .delegatecall _ _ _ _ _ _ => false
| .add a b | .sub a b | .mul a b | .div a b | .sdiv a b | .mod a b | .smod a b
| .bitAnd a b | .bitOr a b | .bitXor a b | .eq a b
| .ge a b | .gt a b | .sgt a b | .lt a b | .slt a b | .le a b
| .logicalAnd a b | .logicalOr a b =>
exprTouchesInternalHelperSurface a || exprTouchesInternalHelperSurface b
| .min a b | .max a b | .wMulDown a b | .wDivUp a b | .ceilDiv a b =>
exprTouchesInternalHelperSurface a || exprTouchesInternalHelperSurface b
| .mapping _ b | .mappingUint _ b | .arrayElement _ b | .storageArrayElement _ b =>
exprTouchesInternalHelperSurface b
| .mappingChain _ [] => false
| .mappingChain field (k :: ks) =>
exprTouchesInternalHelperSurface k || exprTouchesInternalHelperSurface (.mappingChain field ks)
| .bitNot a | .logicalNot a | .mappingWord _ a _ | .mappingPackedWord _ a _ _
| .structMember _ a _ => exprTouchesInternalHelperSurface a
| .ite cond thenVal elseVal =>
exprTouchesInternalHelperSurface cond ||
exprTouchesInternalHelperSurface thenVal ||
exprTouchesInternalHelperSurface elseVal
| .mapping2 _ a b | .mapping2Word _ a b _ | .structMember2 _ a b _ =>
exprTouchesInternalHelperSurface a || exprTouchesInternalHelperSurface b
| .mulDivDown a b c | .mulDivUp a b c =>
exprTouchesInternalHelperSurface a ||
exprTouchesInternalHelperSurface b ||
exprTouchesInternalHelperSurface c
| .shl a b | .shr a b | .sar a b | .signextend a b =>
exprTouchesInternalHelperSurface a || exprTouchesInternalHelperSurface b
| .dynamicBytesEq _ _ => false
/-- Foreign-call/library-hook surfaces still outside the current generic
whole-contract theorem. -/
def exprTouchesUnsupportedForeignSurface : Expr → Bool
| .externalCall _ _ => true
| .literal _ | .param _ | .caller | .contractAddress
| .chainid | .msgValue | .blockTimestamp | .blockNumber
| .localVar _ | .storage _ | .storageAddr _
| .constructorArg _ | .blobbasefee | .mload _ | .tload _
| .calldatasize | .calldataload _ | .returndataSize | .extcodesize _
| .returndataOptionalBoolAt _ | .keccak256 _ _ | .arrayLength _
| .storageArrayLength _ | .internalCall _ _ => false
| .call _ _ _ _ _ _ _ | .staticcall _ _ _ _ _ _ | .delegatecall _ _ _ _ _ _ => false
| .add a b | .sub a b | .mul a b | .div a b | .sdiv a b | .mod a b | .smod a b
| .bitAnd a b | .bitOr a b | .bitXor a b | .eq a b
| .ge a b | .gt a b | .sgt a b | .lt a b | .slt a b | .le a b
| .logicalAnd a b | .logicalOr a b =>
exprTouchesUnsupportedForeignSurface a || exprTouchesUnsupportedForeignSurface b
| .min a b | .max a b | .wMulDown a b | .wDivUp a b | .ceilDiv a b =>
exprTouchesUnsupportedForeignSurface a || exprTouchesUnsupportedForeignSurface b
| .mapping _ b | .mappingUint _ b | .arrayElement _ b | .storageArrayElement _ b =>
exprTouchesUnsupportedForeignSurface b
| .mappingChain _ _ => true
| .bitNot a | .logicalNot a | .mappingWord _ a _ | .mappingPackedWord _ a _ _
| .structMember _ a _ => exprTouchesUnsupportedForeignSurface a
| .ite cond thenVal elseVal =>
exprTouchesUnsupportedForeignSurface cond ||
exprTouchesUnsupportedForeignSurface thenVal ||
exprTouchesUnsupportedForeignSurface elseVal
| .mapping2 _ a b | .mapping2Word _ a b _ | .structMember2 _ a b _ =>
exprTouchesUnsupportedForeignSurface a || exprTouchesUnsupportedForeignSurface b
| .mulDivDown a b c | .mulDivUp a b c =>
exprTouchesUnsupportedForeignSurface a ||
exprTouchesUnsupportedForeignSurface b ||
exprTouchesUnsupportedForeignSurface c
| .shl a b | .shr a b | .sar a b | .signextend a b =>
exprTouchesUnsupportedForeignSurface a || exprTouchesUnsupportedForeignSurface b
| .dynamicBytesEq _ _ => false
/-- Low-level call/runtime-mechanic surfaces still outside the current generic
whole-contract theorem. -/
def exprTouchesUnsupportedLowLevelSurface : Expr → Bool
| .call _ _ _ _ _ _ _ | .staticcall _ _ _ _ _ _ | .delegatecall _ _ _ _ _ _ => true
| .literal _ | .param _ | .caller | .contractAddress
| .chainid | .msgValue | .blockTimestamp | .blockNumber
| .localVar _ | .storage _ | .storageAddr _
| .constructorArg _ | .blobbasefee | .mload _ | .tload _
| .calldatasize | .calldataload _ | .returndataSize | .extcodesize _
| .returndataOptionalBoolAt _ | .keccak256 _ _ | .arrayLength _
| .storageArrayLength _ | .internalCall _ _ | .externalCall _ _ => false
| .add a b | .sub a b | .mul a b | .div a b | .sdiv a b | .mod a b | .smod a b
| .bitAnd a b | .bitOr a b | .bitXor a b | .eq a b
| .ge a b | .gt a b | .sgt a b | .lt a b | .slt a b | .le a b
| .logicalAnd a b | .logicalOr a b =>
exprTouchesUnsupportedLowLevelSurface a || exprTouchesUnsupportedLowLevelSurface b
| .min a b | .max a b | .wMulDown a b | .wDivUp a b | .ceilDiv a b =>
exprTouchesUnsupportedLowLevelSurface a || exprTouchesUnsupportedLowLevelSurface b
| .mapping _ b | .mappingUint _ b | .arrayElement _ b | .storageArrayElement _ b =>
exprTouchesUnsupportedLowLevelSurface b
| .mappingChain _ _ => true
| .bitNot a | .logicalNot a | .mappingWord _ a _ | .mappingPackedWord _ a _ _
| .structMember _ a _ => exprTouchesUnsupportedLowLevelSurface a
| .ite cond thenVal elseVal =>
exprTouchesUnsupportedLowLevelSurface cond ||
exprTouchesUnsupportedLowLevelSurface thenVal ||
exprTouchesUnsupportedLowLevelSurface elseVal
| .mapping2 _ a b | .mapping2Word _ a b _ | .structMember2 _ a b _ =>
exprTouchesUnsupportedLowLevelSurface a || exprTouchesUnsupportedLowLevelSurface b
| .mulDivDown a b c | .mulDivUp a b c =>
exprTouchesUnsupportedLowLevelSurface a ||
exprTouchesUnsupportedLowLevelSurface b ||
exprTouchesUnsupportedLowLevelSurface c
| .shl a b | .shr a b | .sar a b | .signextend a b =>
exprTouchesUnsupportedLowLevelSurface a || exprTouchesUnsupportedLowLevelSurface b
| .dynamicBytesEq _ _ => false
/-- Compatibility expression scan retained for the current generic-induction
proofs. This intentionally preserves the pre-interface split meaning so the
generic-induction boundary does not silently widen or tighten while the new
feature-local interfaces are introduced alongside it. -/
def exprTouchesUnsupportedContractSurface (expr : Expr) : Bool :=
match expr with
| .literal _ | .param _ | .caller | .contractAddress
| .chainid | .msgValue | .blockTimestamp | .blockNumber
| .localVar _ => false
| .storage _ | .storageAddr _ => true
| .add a b | .sub a b | .mul a b | .div a b | .mod a b
| .bitAnd a b | .bitOr a b | .bitXor a b | .eq a b
| .ge a b | .gt a b | .lt a b | .le a b
| .logicalAnd a b | .logicalOr a b =>
exprTouchesUnsupportedContractSurface a || exprTouchesUnsupportedContractSurface b
| .bitNot a | .logicalNot a => exprTouchesUnsupportedContractSurface a
| .min _ _ | .max _ _ | .wMulDown _ _ | .wDivUp _ _ | .ceilDiv _ _
| .ite _ _ _
| .mapping _ _ | .mappingWord _ _ _ | .mappingPackedWord _ _ _ _
| .mapping2 _ _ _ | .mapping2Word _ _ _ _ | .mappingUint _ _ | .mappingChain _ _
| .structMember _ _ _ | .structMember2 _ _ _ _
| .constructorArg _ | .blobbasefee | .mload _ | .tload _ | .keccak256 _ _
| .call _ _ _ _ _ _ _ | .staticcall _ _ _ _ _ _ | .delegatecall _ _ _ _ _ _
| .calldatasize | .calldataload _ | .returndataSize | .extcodesize _
| .returndataOptionalBoolAt _ | .externalCall _ _ | .internalCall _ _
| .arrayLength _ | .arrayElement _ _ | .storageArrayLength _ | .storageArrayElement _ _
| .sdiv _ _ | .smod _ _ | .sgt _ _ | .slt _ _
| .mulDivDown _ _ _ | .mulDivUp _ _ _ | .shl _ _
| .shr _ _ | .sar _ _ | .signextend _ _
| .dynamicBytesEq _ _ => true
mutual
/-- Observable/effect-rich surfaces outside the current generic whole-contract
theorem: richer returns, logs, typed errors, and raw external effect hooks. -/
def stmtTouchesUnsupportedEffectSurface : Stmt → Bool
| .requireError _ _ _ | .revertError _ _ | .returnValues _ | .returnArray _
| .returnBytes _ | .returnStorageWords _ | .emit _ _ | .rawLog _ _ _
| .externalCallBind _ _ _ | .ecm _ _ => true
| .letVar _ _ | .assignVar _ _ | .setStorage _ _ | .setStorageAddr _ _
| .require _ _ | .return _ | .mstore _ _ | .tstore _ _ | .stop
| .setMapping _ _ _ | .setMappingWord _ _ _ _
| .setMappingPackedWord _ _ _ _ _ | .setMapping2 _ _ _ _
| .setMapping2Word _ _ _ _ _ | .setMappingUint _ _ _ | .setMappingChain _ _ _
| .setStructMember _ _ _ _ | .setStructMember2 _ _ _ _ _
| .storageArrayPush _ _ | .storageArrayPop _ | .setStorageArrayElement _ _ _
| .calldatacopy _ _ _ | .returndataCopy _ _ _ | .revertReturndata
| .internalCall _ _ | .internalCallAssign _ _ _ => false
| .ite _ thenBranch elseBranch =>
stmtListTouchesUnsupportedEffectSurface thenBranch ||
stmtListTouchesUnsupportedEffectSurface elseBranch
| .forEach _ _ body =>
stmtListTouchesUnsupportedEffectSurface body
/-- Statement forms intentionally still outside the current generic-induction
core, excluding richer state/call/effect surfaces that now have dedicated
interfaces of their own. -/
def stmtTouchesUnsupportedCoreSurface : Stmt → Bool
| .letVar _ value | .assignVar _ value | .setStorage _ value =>
exprTouchesUnsupportedCoreSurface value
| .setStorageAddr _ value =>
exprTouchesUnsupportedCoreSurface value
| .setMapping _ key value | .setMappingWord _ key _ value
| .setMappingPackedWord _ key _ _ value | .setMappingUint _ key value
| .setStructMember _ key _ value =>
exprTouchesUnsupportedCoreSurface key ||
exprTouchesUnsupportedCoreSurface value
| .setMappingChain _ keys value =>
keys.any exprTouchesUnsupportedCoreSurface ||
exprTouchesUnsupportedCoreSurface value
| .setMapping2 _ key1 key2 value | .setMapping2Word _ key1 key2 _ value
| .setStructMember2 _ key1 key2 _ value =>
exprTouchesUnsupportedCoreSurface key1 ||
exprTouchesUnsupportedCoreSurface key2 ||
exprTouchesUnsupportedCoreSurface value
| .storageArrayPush _ value =>
exprTouchesUnsupportedCoreSurface value
| .setStorageArrayElement _ index value =>
exprTouchesUnsupportedCoreSurface index ||
exprTouchesUnsupportedCoreSurface value
| .mstore offset value | .tstore offset value =>
exprTouchesUnsupportedCoreSurface offset ||
exprTouchesUnsupportedCoreSurface value
| .require cond _ | .return cond =>
exprTouchesUnsupportedCoreSurface cond
| .stop => false
| .ite _ _ _ | .forEach _ _ _ => true
| .storageArrayPop _
| .requireError _ _ _ | .revertError _ _ | .returnValues _ | .returnArray _
| .returnBytes _ | .returnStorageWords _ | .calldatacopy _ _ _
| .returndataCopy _ _ _ | .revertReturndata
| .emit _ _ | .internalCall _ _ | .internalCallAssign _ _ _
| .rawLog _ _ _ | .externalCallBind _ _ _ | .ecm _ _ => false
/-- State/layout-rich statement surfaces still outside the current whole-contract
theorem. -/
def stmtTouchesUnsupportedStateSurface : Stmt → Bool
| .letVar _ value | .assignVar _ value | .setStorage _ value =>
exprTouchesUnsupportedStateSurface value
| .require cond _ | .return cond =>
exprTouchesUnsupportedStateSurface cond
| .setStorageAddr _ value =>
exprTouchesUnsupportedStateSurface value
| .setMapping _ _ _ | .setMappingWord _ _ _ _ | .setMappingPackedWord _ _ _ _ _
| .setMapping2 _ _ _ _ | .setMapping2Word _ _ _ _ _ | .setMappingUint _ _ _
| .setMappingChain _ _ _
| .setStructMember _ _ _ _ | .setStructMember2 _ _ _ _ _
| .storageArrayPush _ _ | .storageArrayPop _ | .setStorageArrayElement _ _ _ => true
| .mstore offset value | .tstore offset value =>
exprTouchesUnsupportedStateSurface offset ||
exprTouchesUnsupportedStateSurface value
| .stop
| .requireError _ _ _ | .revertError _ _ | .returnValues _ | .returnArray _
| .returnBytes _ | .returnStorageWords _ | .calldatacopy _ _ _
| .returndataCopy _ _ _ | .revertReturndata
| .emit _ _ | .internalCall _ _ | .internalCallAssign _ _ _
| .rawLog _ _ _ | .externalCallBind _ _ _ | .ecm _ _ => false
| .ite cond thenBranch elseBranch =>
exprTouchesUnsupportedStateSurface cond ||
stmtListTouchesUnsupportedStateSurface thenBranch ||
stmtListTouchesUnsupportedStateSurface elseBranch
| .forEach _ count body =>
exprTouchesUnsupportedStateSurface count ||
stmtListTouchesUnsupportedStateSurface body
/-- Weaker Tier 2 state-surface gate used by the singleton storage-write bridge:
all existing unsupported stateful forms remain excluded except for the proved
singleton mapping-write heads. -/
def stmtTouchesUnsupportedStateSurfaceExceptMappingWrites : Stmt → Bool
| .setMapping _ _ _ | .setMappingWord _ _ _ _ | .setMappingPackedWord _ _ _ _ _
| .setMappingUint _ _ _ | .setStructMember _ _ _ _ | .setMappingChain _ _ _
| .setMapping2 _ _ _ _ | .setMapping2Word _ _ _ _ _ | .setStructMember2 _ _ _ _ _ =>
false
| stmt => stmtTouchesUnsupportedStateSurface stmt
/-- Helper/foreign/runtime-call statement surfaces still outside the current
generic theorem. -/
def stmtTouchesUnsupportedCallSurface : Stmt → Bool
| .letVar _ value | .assignVar _ value | .setStorage _ value
| .setStorageAddr _ value | .storageArrayPush _ value =>
exprTouchesUnsupportedCallSurface value
| .setMapping _ key value | .setMappingWord _ key _ value
| .setMappingPackedWord _ key _ _ value | .setMappingUint _ key value
| .setStructMember _ key _ value =>
exprTouchesUnsupportedCallSurface key ||
exprTouchesUnsupportedCallSurface value
| .setMappingChain _ keys value =>
keys.any exprTouchesUnsupportedCallSurface ||
exprTouchesUnsupportedCallSurface value
| .setMapping2 _ key1 key2 value | .setMapping2Word _ key1 key2 _ value
| .setStructMember2 _ key1 key2 _ value =>
exprTouchesUnsupportedCallSurface key1 ||
exprTouchesUnsupportedCallSurface key2 ||
exprTouchesUnsupportedCallSurface value
| .setStorageArrayElement _ index value
| .mstore index value | .tstore index value =>
exprTouchesUnsupportedCallSurface index ||
exprTouchesUnsupportedCallSurface value
| .require cond _ | .return cond =>
exprTouchesUnsupportedCallSurface cond
| .internalCall _ _ | .internalCallAssign _ _ _ => true
| .calldatacopy _ _ _
| .returndataCopy _ _ _ | .revertReturndata | .externalCallBind _ _ _
| .ecm _ _ => true
| .stop | .storageArrayPop _
| .requireError _ _ _ | .revertError _ _ | .returnValues _ | .returnArray _
| .returnBytes _ | .returnStorageWords _ | .emit _ _ | .rawLog _ _ _ => false
| .ite cond thenBranch elseBranch =>
exprTouchesUnsupportedCallSurface cond ||
stmtListTouchesUnsupportedCallSurface thenBranch ||
stmtListTouchesUnsupportedCallSurface elseBranch
| .forEach _ count body =>
exprTouchesUnsupportedCallSurface count ||
stmtListTouchesUnsupportedCallSurface body
def stmtTouchesUnsupportedHelperSurface : Stmt → Bool
| .letVar _ value | .assignVar _ value | .setStorage _ value
| .setStorageAddr _ value | .storageArrayPush _ value =>
exprTouchesUnsupportedHelperSurface value
| .setMapping _ key value | .setMappingWord _ key _ value
| .setMappingPackedWord _ key _ _ value | .setMappingUint _ key value
| .setStructMember _ key _ value =>
exprTouchesUnsupportedHelperSurface key ||
exprTouchesUnsupportedHelperSurface value
| .setMappingChain _ keys value =>
exprListTouchesUnsupportedHelperSurface keys ||
exprTouchesUnsupportedHelperSurface value
| .setMapping2 _ key1 key2 value | .setMapping2Word _ key1 key2 _ value
| .setStructMember2 _ key1 key2 _ value =>
exprTouchesUnsupportedHelperSurface key1 ||
exprTouchesUnsupportedHelperSurface key2 ||
exprTouchesUnsupportedHelperSurface value
| .setStorageArrayElement _ index value
| .mstore index value | .tstore index value =>
exprTouchesUnsupportedHelperSurface index ||
exprTouchesUnsupportedHelperSurface value
| .require cond _ | .return cond =>
exprTouchesUnsupportedHelperSurface cond
| .internalCall _ _ | .internalCallAssign _ _ _ => true
| .stop | .calldatacopy _ _ _
| .returndataCopy _ _ _ | .revertReturndata | .externalCallBind _ _ _
| .ecm _ _ | .storageArrayPop _
| .requireError _ _ _ | .revertError _ _ | .returnValues _ | .returnArray _
| .returnBytes _ | .returnStorageWords _ | .emit _ _ | .rawLog _ _ _ => false
| .ite cond thenBranch elseBranch =>
exprTouchesUnsupportedHelperSurface cond ||
stmtListTouchesUnsupportedHelperSurface thenBranch ||
stmtListTouchesUnsupportedHelperSurface elseBranch
| .forEach _ count body =>
exprTouchesUnsupportedHelperSurface count ||
stmtListTouchesUnsupportedHelperSurface body
/-- Narrow helper-effect surface used by the exact helper-aware induction seam:
this isolates heads that genuinely execute internal helpers, leaving residual
non-helper unsupported cases to be tracked separately. -/
def stmtTouchesInternalHelperSurface : Stmt → Bool
| .letVar _ value | .assignVar _ value | .setStorage _ value
| .setStorageAddr _ value | .storageArrayPush _ value =>
exprTouchesInternalHelperSurface value
| .setMapping _ key value | .setMappingWord _ key _ value
| .setMappingPackedWord _ key _ _ value | .setMappingUint _ key value
| .setStructMember _ key _ value =>
exprTouchesInternalHelperSurface key ||
exprTouchesInternalHelperSurface value
| .setMappingChain _ keys value =>
keys.any exprTouchesInternalHelperSurface ||
exprTouchesInternalHelperSurface value
| .setMapping2 _ key1 key2 value | .setMapping2Word _ key1 key2 _ value
| .setStructMember2 _ key1 key2 _ value =>
exprTouchesInternalHelperSurface key1 ||
exprTouchesInternalHelperSurface key2 ||
exprTouchesInternalHelperSurface value
| .setStorageArrayElement _ index value
| .mstore index value | .tstore index value =>
exprTouchesInternalHelperSurface index ||
exprTouchesInternalHelperSurface value
| .require cond _ | .return cond =>
exprTouchesInternalHelperSurface cond
| .internalCall _ _ | .internalCallAssign _ _ _ => true
| .stop | .calldatacopy _ _ _
| .returndataCopy _ _ _ | .revertReturndata | .externalCallBind _ _ _
| .ecm _ _ | .storageArrayPop _ | .requireError _ _ _
| .revertError _ _ | .returnValues _ | .returnArray _
| .returnBytes _ | .returnStorageWords _ | .emit _ _
| .rawLog _ _ _ => false
| .ite cond thenBranch elseBranch =>
exprTouchesInternalHelperSurface cond ||
stmtListTouchesInternalHelperSurface thenBranch ||
stmtListTouchesInternalHelperSurface elseBranch
| .forEach _ count body =>
exprTouchesInternalHelperSurface count ||
stmtListTouchesInternalHelperSurface body
/-- Direct statement-position internal helper execution. This is the part of the
exact helper seam that should consume the existing statement-level helper
summary lemmas from `SourceSemantics.lean`. -/
def stmtTouchesDirectInternalHelperSurface : Stmt → Bool
| .internalCall _ _ =>
true
| .internalCallAssign _ _ _ =>
true
| _ => false
/-- Direct helper statements with no source-level return binding. These match
the `Stmt.internalCall` source-summary shape exactly. -/
def stmtTouchesDirectInternalHelperCallSurface : Stmt → Bool
| .internalCall _ _ => true
| _ => false
/-- Direct helper statements that bind helper returns into source locals. These
match the `Stmt.internalCallAssign` source-summary shape exactly. -/
def stmtTouchesDirectInternalHelperAssignSurface : Stmt → Bool
| .internalCallAssign _ _ _ => true
| _ => false
/-- Expression-position internal helper execution at the current statement head.
This isolates the cases that should consume the expression-level helper-summary
soundness and world-preservation lemmas directly, rather than bundling them
with direct helper statements or recursive structural transport. -/
def stmtTouchesExprInternalHelperSurface : Stmt → Bool
| .letVar _ value | .assignVar _ value | .setStorage _ value
| .setStorageAddr _ value | .storageArrayPush _ value =>
exprTouchesInternalHelperSurface value
| .setMapping _ key value | .setMappingWord _ key _ value
| .setMappingPackedWord _ key _ _ value | .setMappingUint _ key value
| .setStructMember _ key _ value =>
exprTouchesInternalHelperSurface key ||
exprTouchesInternalHelperSurface value
| .setMappingChain _ keys value =>
keys.any exprTouchesInternalHelperSurface ||
exprTouchesInternalHelperSurface value
| .setMapping2 _ key1 key2 value | .setMapping2Word _ key1 key2 _ value
| .setStructMember2 _ key1 key2 _ value =>
exprTouchesInternalHelperSurface key1 ||
exprTouchesInternalHelperSurface key2 ||
exprTouchesInternalHelperSurface value
| .setStorageArrayElement _ index value
| .mstore index value | .tstore index value =>
exprTouchesInternalHelperSurface index ||
exprTouchesInternalHelperSurface value
| .require cond _ | .return cond =>
exprTouchesInternalHelperSurface cond
| .ite cond _ _ =>
exprTouchesInternalHelperSurface cond
| .forEach _ count _ =>
exprTouchesInternalHelperSurface count
| .internalCall _ _ | .internalCallAssign _ _ _ | .stop
| .calldatacopy _ _ _ | .returndataCopy _ _ _
| .revertReturndata | .externalCallBind _ _ _ | .ecm _ _
| .storageArrayPop _ | .requireError _ _ _
| .revertError _ _ | .returnValues _ | .returnArray _
| .returnBytes _ | .returnStorageWords _ | .emit _ _
| .rawLog _ _ _ => false
/-- Recursive structural internal-helper transport at the current statement
head. This isolates `ite` / `forEach` obligations whose proof burden is mainly
list-level recursion rather than direct helper-summary consumption. -/
def stmtTouchesStructuralInternalHelperSurface : Stmt → Bool
| .ite _ thenBranch elseBranch =>
stmtListTouchesInternalHelperSurface thenBranch ||
stmtListTouchesInternalHelperSurface elseBranch
| .forEach _ _ body =>
stmtListTouchesInternalHelperSurface body
| .letVar _ _ | .assignVar _ _ | .setStorage _ _ | .require _ _
| .return _ | .internalCall _ _ | .internalCallAssign _ _ _
| .stop | .setStorageAddr _ _ | .mstore _ _ | .tstore _ _
| .calldatacopy _ _ _ | .returndataCopy _ _ _
| .revertReturndata | .externalCallBind _ _ _ | .ecm _ _
| .setMapping _ _ _ | .setMappingWord _ _ _ _
| .setMappingPackedWord _ _ _ _ _ | .setMapping2 _ _ _ _
| .setMapping2Word _ _ _ _ _ | .setMappingUint _ _ _
| .setMappingChain _ _ _
| .setStructMember _ _ _ _ | .setStructMember2 _ _ _ _ _
| .storageArrayPush _ _ | .storageArrayPop _
| .setStorageArrayElement _ _ _ | .requireError _ _ _
| .revertError _ _ | .returnValues _ | .returnArray _
| .returnBytes _ | .returnStorageWords _ | .emit _ _
| .rawLog _ _ _ => false
def stmtTouchesUnsupportedForeignSurface : Stmt → Bool
| .letVar _ value | .assignVar _ value | .setStorage _ value
| .setStorageAddr _ value | .storageArrayPush _ value =>
exprTouchesUnsupportedForeignSurface value
| .setMapping _ key value | .setMappingWord _ key _ value
| .setMappingPackedWord _ key _ _ value | .setMappingUint _ key value
| .setStructMember _ key _ value =>
exprTouchesUnsupportedForeignSurface key ||
exprTouchesUnsupportedForeignSurface value
| .setMappingChain _ keys value =>
keys.any exprTouchesUnsupportedForeignSurface ||
exprTouchesUnsupportedForeignSurface value
| .setMapping2 _ key1 key2 value | .setMapping2Word _ key1 key2 _ value
| .setStructMember2 _ key1 key2 _ value =>
exprTouchesUnsupportedForeignSurface key1 ||
exprTouchesUnsupportedForeignSurface key2 ||
exprTouchesUnsupportedForeignSurface value
| .setStorageArrayElement _ index value
| .mstore index value | .tstore index value =>
exprTouchesUnsupportedForeignSurface index ||
exprTouchesUnsupportedForeignSurface value
| .require cond _ | .return cond =>
exprTouchesUnsupportedForeignSurface cond
| .externalCallBind _ _ _ | .ecm _ _ => true
| .stop
| .internalCall _ _ | .internalCallAssign _ _ _
| .calldatacopy _ _ _ | .returndataCopy _ _ _ | .revertReturndata
| .storageArrayPop _
| .requireError _ _ _ | .revertError _ _ | .returnValues _ | .returnArray _
| .returnBytes _ | .returnStorageWords _ | .emit _ _ | .rawLog _ _ _ => false
| .ite cond thenBranch elseBranch =>
exprTouchesUnsupportedForeignSurface cond ||
stmtListTouchesUnsupportedForeignSurface thenBranch ||
stmtListTouchesUnsupportedForeignSurface elseBranch
| .forEach _ count body =>
exprTouchesUnsupportedForeignSurface count ||
stmtListTouchesUnsupportedForeignSurface body
def stmtTouchesUnsupportedLowLevelSurface : Stmt → Bool
| .letVar _ value | .assignVar _ value | .setStorage _ value
| .setStorageAddr _ value | .storageArrayPush _ value =>
exprTouchesUnsupportedLowLevelSurface value
| .setMapping _ key value | .setMappingWord _ key _ value
| .setMappingPackedWord _ key _ _ value | .setMappingUint _ key value
| .setStructMember _ key _ value =>
exprTouchesUnsupportedLowLevelSurface key ||
exprTouchesUnsupportedLowLevelSurface value
| .setMappingChain _ keys value =>
keys.any exprTouchesUnsupportedLowLevelSurface ||
exprTouchesUnsupportedLowLevelSurface value
| .setMapping2 _ key1 key2 value | .setMapping2Word _ key1 key2 _ value
| .setStructMember2 _ key1 key2 _ value =>
exprTouchesUnsupportedLowLevelSurface key1 ||
exprTouchesUnsupportedLowLevelSurface key2 ||
exprTouchesUnsupportedLowLevelSurface value
| .setStorageArrayElement _ index value
| .mstore index value | .tstore index value =>
exprTouchesUnsupportedLowLevelSurface index ||
exprTouchesUnsupportedLowLevelSurface value
| .require cond _ | .return cond =>
exprTouchesUnsupportedLowLevelSurface cond
| .calldatacopy _ _ _
| .returndataCopy _ _ _ | .revertReturndata => true
| .stop
| .internalCall _ _ | .internalCallAssign _ _ _ | .externalCallBind _ _ _
| .ecm _ _ | .storageArrayPop _
| .requireError _ _ _ | .revertError _ _ | .returnValues _ | .returnArray _
| .returnBytes _ | .returnStorageWords _ | .emit _ _ | .rawLog _ _ _ => false
| .ite cond thenBranch elseBranch =>
exprTouchesUnsupportedLowLevelSurface cond ||
stmtListTouchesUnsupportedLowLevelSurface thenBranch ||
stmtListTouchesUnsupportedLowLevelSurface elseBranch
| .forEach _ count body =>
exprTouchesUnsupportedLowLevelSurface count ||
stmtListTouchesUnsupportedLowLevelSurface body
def stmtTouchesUnsupportedContractSurface (stmt : Stmt) : Bool :=
match stmt with
| .letVar _ value | .assignVar _ value | .setStorage _ value =>
exprTouchesUnsupportedContractSurface value
| .setStorageAddr _ value =>
exprTouchesUnsupportedContractSurface value
| .require cond _ | .return cond =>
exprTouchesUnsupportedContractSurface cond
| .mstore offset value | .tstore offset value =>
exprTouchesUnsupportedContractSurface offset ||
exprTouchesUnsupportedContractSurface value
| .stop => false
| .ite _ _ _ => true
| .setMapping _ _ _ | .setMappingWord _ _ _ _ | .setMappingPackedWord _ _ _ _ _
| .setMapping2 _ _ _ _ | .setMapping2Word _ _ _ _ _ | .setMappingUint _ _ _
| .setMappingChain _ _ _
| .setStructMember _ _ _ _ | .setStructMember2 _ _ _ _ _
| .storageArrayPush _ _ | .storageArrayPop _ | .setStorageArrayElement _ _ _
| .requireError _ _ _ | .revertError _ _ | .returnValues _ | .returnArray _
| .returnBytes _ | .returnStorageWords _ | .calldatacopy _ _ _
| .returndataCopy _ _ _ | .revertReturndata | .forEach _ _ _
| .emit _ _ | .internalCall _ _ | .internalCallAssign _ _ _
| .rawLog _ _ _ | .externalCallBind _ _ _ | .ecm _ _ => true
/-- Weaker contract-surface gate used by the Tier 2 singleton storage-write
bridge: ordinary unsupported contract effects remain excluded, but the proved
singleton mapping-write heads are admitted. -/
def stmtTouchesUnsupportedContractSurfaceExceptMappingWrites (stmt : Stmt) : Bool :=
match stmt with
| .setMapping _ _ _ | .setMappingWord _ _ _ _ | .setMappingPackedWord _ _ _ _ _
| .setMappingUint _ _ _ | .setStructMember _ _ _ _ | .setMappingChain _ _ _
| .setMapping2 _ _ _ _ | .setMapping2Word _ _ _ _ _ | .setStructMember2 _ _ _ _ _ =>
false
| _ => stmtTouchesUnsupportedContractSurface stmt
def stmtListTouchesUnsupportedCoreSurface : List Stmt → Bool
| [] => false
| stmt :: rest =>
stmtTouchesUnsupportedCoreSurface stmt ||
stmtListTouchesUnsupportedCoreSurface rest
def stmtListTouchesUnsupportedStateSurface : List Stmt → Bool
| [] => false
| stmt :: rest =>
stmtTouchesUnsupportedStateSurface stmt ||
stmtListTouchesUnsupportedStateSurface rest
def stmtListTouchesUnsupportedStateSurfaceExceptMappingWrites : List Stmt → Bool
| [] => false
| stmt :: rest =>
stmtTouchesUnsupportedStateSurfaceExceptMappingWrites stmt ||
stmtListTouchesUnsupportedStateSurfaceExceptMappingWrites rest
def stmtListTouchesUnsupportedCallSurface : List Stmt → Bool
| [] => false
| stmt :: rest =>
stmtTouchesUnsupportedCallSurface stmt ||
stmtListTouchesUnsupportedCallSurface rest
def stmtListTouchesUnsupportedHelperSurface : List Stmt → Bool
| [] => false
| stmt :: rest =>
stmtTouchesUnsupportedHelperSurface stmt ||
stmtListTouchesUnsupportedHelperSurface rest
/-- List-level narrow helper-effect surface used to target only genuine
internal-helper execution in the exact helper-aware induction seam. -/
def stmtListTouchesInternalHelperSurface : List Stmt → Bool
| [] => false
| stmt :: rest =>
stmtTouchesInternalHelperSurface stmt ||
stmtListTouchesInternalHelperSurface rest
def stmtListTouchesDirectInternalHelperSurface : List Stmt → Bool
| [] => false
| stmt :: rest =>
stmtTouchesDirectInternalHelperSurface stmt ||
stmtListTouchesDirectInternalHelperSurface rest
def stmtListTouchesDirectInternalHelperCallSurface : List Stmt → Bool
| [] => false
| stmt :: rest =>
stmtTouchesDirectInternalHelperCallSurface stmt ||
stmtListTouchesDirectInternalHelperCallSurface rest
def stmtListTouchesDirectInternalHelperAssignSurface : List Stmt → Bool
| [] => false
| stmt :: rest =>
stmtTouchesDirectInternalHelperAssignSurface stmt ||
stmtListTouchesDirectInternalHelperAssignSurface rest
def stmtListTouchesExprInternalHelperSurface : List Stmt → Bool
| [] => false
| stmt :: rest =>
stmtTouchesExprInternalHelperSurface stmt ||
stmtListTouchesExprInternalHelperSurface rest
def stmtListTouchesStructuralInternalHelperSurface : List Stmt → Bool
| [] => false
| stmt :: rest =>
stmtTouchesStructuralInternalHelperSurface stmt ||
stmtListTouchesStructuralInternalHelperSurface rest
def stmtListTouchesUnsupportedForeignSurface : List Stmt → Bool
| [] => false
| stmt :: rest =>
stmtTouchesUnsupportedForeignSurface stmt ||
stmtListTouchesUnsupportedForeignSurface rest
def stmtListTouchesUnsupportedLowLevelSurface : List Stmt → Bool
| [] => false
| stmt :: rest =>
stmtTouchesUnsupportedLowLevelSurface stmt ||
stmtListTouchesUnsupportedLowLevelSurface rest
def stmtListTouchesUnsupportedEffectSurface : List Stmt → Bool
| [] => false
| stmt :: rest =>
stmtTouchesUnsupportedEffectSurface stmt ||
stmtListTouchesUnsupportedEffectSurface rest
/-- List-level weakening of `stmtListTouchesUnsupportedContractSurface` used by
the Tier 2 singleton mapping-write bridge. -/
def stmtListTouchesUnsupportedContractSurfaceExceptMappingWrites : List Stmt → Bool
| [] => false
| stmt :: rest =>
stmtTouchesUnsupportedContractSurfaceExceptMappingWrites stmt ||
stmtListTouchesUnsupportedContractSurfaceExceptMappingWrites rest
end
mutual
/-- Collect direct internal-helper callee names mentioned by an expression. This
inventory is used to define a compositional helper-summary interface without yet
changing the current generic theorem's fail-closed helper boundary. -/
def exprInternalHelperCallNames : Expr → List String
| .internalCall calleeName args =>
calleeName :: exprListInternalHelperCallNames args
| .mapping _ key | .mappingWord _ key _ | .mappingPackedWord _ key _ _
| .mappingUint _ key | .structMember _ key _ | .arrayElement _ key
| .storageArrayElement _ key | .mload key | .tload key | .calldataload key
| .extcodesize key | .returndataOptionalBoolAt key =>
exprInternalHelperCallNames key
| .mappingChain _ keys =>
exprListInternalHelperCallNames keys
| .mapping2 _ key1 key2 | .mapping2Word _ key1 key2 _
| .structMember2 _ key1 key2 _ =>
exprInternalHelperCallNames key1 ++ exprInternalHelperCallNames key2
| .call gas target value inOffset inSize outOffset outSize =>
exprInternalHelperCallNames gas ++ exprInternalHelperCallNames target ++
exprInternalHelperCallNames value ++ exprInternalHelperCallNames inOffset ++
exprInternalHelperCallNames inSize ++ exprInternalHelperCallNames outOffset ++
exprInternalHelperCallNames outSize
| .staticcall gas target inOffset inSize outOffset outSize =>
exprInternalHelperCallNames gas ++ exprInternalHelperCallNames target ++
exprInternalHelperCallNames inOffset ++ exprInternalHelperCallNames inSize ++
exprInternalHelperCallNames outOffset ++ exprInternalHelperCallNames outSize
| .delegatecall gas target inOffset inSize outOffset outSize =>
exprInternalHelperCallNames gas ++ exprInternalHelperCallNames target ++
exprInternalHelperCallNames inOffset ++ exprInternalHelperCallNames inSize ++
exprInternalHelperCallNames outOffset ++ exprInternalHelperCallNames outSize
| .keccak256 offset size =>
exprInternalHelperCallNames offset ++ exprInternalHelperCallNames size
| .add a b | .sub a b | .mul a b | .div a b | .sdiv a b | .mod a b | .smod a b
| .bitAnd a b | .bitOr a b | .bitXor a b | .shl a b | .shr a b | .sar a b
| .signextend a b | .eq a b | .ge a b | .gt a b | .sgt a b | .lt a b
| .slt a b | .le a b | .logicalAnd a b | .logicalOr a b | .wMulDown a b
| .wDivUp a b | .min a b | .max a b | .ceilDiv a b =>
exprInternalHelperCallNames a ++ exprInternalHelperCallNames b
| .mulDivDown a b c | .mulDivUp a b c =>
exprInternalHelperCallNames a ++ exprInternalHelperCallNames b ++
exprInternalHelperCallNames c
| .bitNot a | .logicalNot a =>
exprInternalHelperCallNames a
| .ite cond thenVal elseVal =>
exprInternalHelperCallNames cond ++ exprInternalHelperCallNames thenVal ++
exprInternalHelperCallNames elseVal
| .externalCall _ args =>
exprListInternalHelperCallNames args
| _ =>
[]
termination_by e => sizeOf e
decreasing_by all_goals simp_wf; all_goals omega
def exprListInternalHelperCallNames : List Expr → List String
| [] => []
| expr :: rest =>
exprInternalHelperCallNames expr ++ exprListInternalHelperCallNames rest
termination_by es => sizeOf es
decreasing_by all_goals simp_wf; all_goals omega
end
mutual
/-- Collect direct internal-helper callee names that occur specifically in expression
positions. These calls must preserve the world on success because the current
helper-aware expression semantics returns only a value. -/
def stmtExprHelperCallNames : Stmt → List String
| .letVar _ value | .assignVar _ value | .setStorage _ value | .setStorageAddr _ value
| .storageArrayPush _ value | .return value | .require value _ =>
exprInternalHelperCallNames value
| .setStorageArrayElement _ index value =>
exprInternalHelperCallNames index ++ exprInternalHelperCallNames value
| .requireError cond _ args =>
exprInternalHelperCallNames cond ++ exprListInternalHelperCallNames args
| .revertError _ args | .emit _ args | .returnValues args
| .externalCallBind _ _ args | .ecm _ args =>
exprListInternalHelperCallNames args
| .mstore offset value | .tstore offset value =>
exprInternalHelperCallNames offset ++ exprInternalHelperCallNames value
| .calldatacopy destOffset sourceOffset size
| .returndataCopy destOffset sourceOffset size =>
exprInternalHelperCallNames destOffset ++ exprInternalHelperCallNames sourceOffset ++
exprInternalHelperCallNames size
| .setMapping _ key value | .setMappingWord _ key _ value
| .setMappingPackedWord _ key _ _ value | .setMappingUint _ key value
| .setStructMember _ key _ value =>
exprInternalHelperCallNames key ++ exprInternalHelperCallNames value
| .setMappingChain _ keys value =>
exprListInternalHelperCallNames keys ++ exprInternalHelperCallNames value
| .setMapping2 _ key1 key2 value | .setMapping2Word _ key1 key2 _ value
| .setStructMember2 _ key1 key2 _ value =>
exprInternalHelperCallNames key1 ++ exprInternalHelperCallNames key2 ++
exprInternalHelperCallNames value
| .ite cond thenBranch elseBranch =>
exprInternalHelperCallNames cond ++ stmtListExprHelperCallNames thenBranch ++
stmtListExprHelperCallNames elseBranch
| .forEach _ count body =>
exprInternalHelperCallNames count ++ stmtListExprHelperCallNames body
| .internalCall _ args | .internalCallAssign _ _ args =>
exprListInternalHelperCallNames args
| .rawLog topics dataOffset dataSize =>
exprListInternalHelperCallNames topics ++ exprInternalHelperCallNames dataOffset ++
exprInternalHelperCallNames dataSize
| .storageArrayPop _ | .returnArray _ | .returnBytes _ | .returnStorageWords _
| .revertReturndata | .stop =>
[]
termination_by s => sizeOf s
decreasing_by all_goals simp_wf; all_goals omega
def stmtListExprHelperCallNames : List Stmt → List String
| [] => []
| stmt :: rest =>
stmtExprHelperCallNames stmt ++ stmtListExprHelperCallNames rest
termination_by stmts => sizeOf stmts
decreasing_by all_goals simp_wf; all_goals omega
end
mutual
/-- Collect direct internal-helper callee names mentioned by a statement list. -/
def stmtInternalHelperCallNames : Stmt → List String
| .letVar _ value | .assignVar _ value | .setStorage _ value | .setStorageAddr _ value
| .storageArrayPush _ value | .return value | .require value _ =>
exprInternalHelperCallNames value
| .setStorageArrayElement _ index value =>
exprInternalHelperCallNames index ++ exprInternalHelperCallNames value
| .requireError cond _ args =>
exprInternalHelperCallNames cond ++ exprListInternalHelperCallNames args
| .revertError _ args | .emit _ args | .returnValues args
| .externalCallBind _ _ args | .ecm _ args =>
exprListInternalHelperCallNames args
| .mstore offset value | .tstore offset value =>
exprInternalHelperCallNames offset ++ exprInternalHelperCallNames value
| .calldatacopy destOffset sourceOffset size
| .returndataCopy destOffset sourceOffset size =>
exprInternalHelperCallNames destOffset ++ exprInternalHelperCallNames sourceOffset ++
exprInternalHelperCallNames size
| .setMapping _ key value | .setMappingWord _ key _ value
| .setMappingPackedWord _ key _ _ value | .setMappingUint _ key value
| .setStructMember _ key _ value =>
exprInternalHelperCallNames key ++ exprInternalHelperCallNames value
| .setMappingChain _ keys value =>
exprListInternalHelperCallNames keys ++ exprInternalHelperCallNames value
| .setMapping2 _ key1 key2 value | .setMapping2Word _ key1 key2 _ value
| .setStructMember2 _ key1 key2 _ value =>
exprInternalHelperCallNames key1 ++ exprInternalHelperCallNames key2 ++
exprInternalHelperCallNames value
| .ite cond thenBranch elseBranch =>
exprInternalHelperCallNames cond ++ stmtListInternalHelperCallNames thenBranch ++
stmtListInternalHelperCallNames elseBranch
| .forEach _ count body =>
exprInternalHelperCallNames count ++ stmtListInternalHelperCallNames body
| .internalCall calleeName args =>
calleeName :: exprListInternalHelperCallNames args