-
Notifications
You must be signed in to change notification settings - Fork 0
/
SmallStepTest.v
1354 lines (1244 loc) · 49 KB
/
SmallStepTest.v
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
Require Import BinNat.
Require Import Bool.
Require Import List.
Require Import sflib.
Require Import Omega.
Require Import Lia.
Require Import Common.
Require Import Lang.
Require Import Value.
Require Import Memory.
Require Import State.
Require Import LoadStore.
Require Import SmallStep.
Require Import SmallStepAux.
Require Import Behaviors.
Module Ir.
Module SmallStepTest.
Module GetElementPtr.
(****************************************************
gep poison, idx is always poison.
****************************************************)
Theorem gep_poison1:
forall st md r ptrty op1 opidx inb sr
(HOP1:Ir.Config.get_val st op1 = Some Ir.poison)
(HCUR:Ir.Config.cur_inst md st = Some (Ir.Inst.igep r ptrty op1 opidx inb))
(HINST:Ir.SmallStep.inst_step md st sr),
sr = Ir.SmallStep.sr_success
Ir.e_none (* no event *)
(* new state, with PC incremented & r := poison *)
(Ir.SmallStep.update_reg_and_incrpc md st r Ir.poison).
Proof.
intros.
inv HINST; try congruence.
unfold Ir.SmallStep.inst_det_step in HNEXT. rewrite HCUR in HNEXT.
inv HNEXT. des_ifs.
Qed.
(****************************************************
gep ptr, poison is always poison.
****************************************************)
Theorem gep_poison2:
forall st md r ptrty op1 opidx inb sr
(HOP1:Ir.Config.get_val st opidx = Some Ir.poison)
(HCUR:Ir.Config.cur_inst md st = Some (Ir.Inst.igep r ptrty op1 opidx inb))
(HINST:Ir.SmallStep.inst_step md st sr),
sr = Ir.SmallStep.sr_success
Ir.e_none (* no event *)
(* new state, with PC incremented & r := poison *)
(Ir.SmallStep.update_reg_and_incrpc md st r Ir.poison).
Proof.
intros.
inv HINST; try congruence.
unfold Ir.SmallStep.inst_det_step in HNEXT. rewrite HCUR in HNEXT.
inv HNEXT. des_ifs.
Qed.
(****************************************************
gep log(l, 10), 5 is log(l, 15).
****************************************************)
Theorem gep_logical1:
forall st md r ptrty op1 opidx sr l
(HOP1:Ir.Config.get_val st op1 = Some (Ir.ptr (Ir.plog l 10)))
(HOP2:Ir.Config.get_val st opidx = Some (Ir.num 5))
(HCUR:Ir.Config.cur_inst md st = Some (Ir.Inst.igep r (Ir.ptrty ptrty) op1 opidx false))
(HSZ:Ir.ty_bytesz ptrty = 1)
(HINST:Ir.SmallStep.inst_step md st sr),
sr = Ir.SmallStep.sr_success
Ir.e_none (* no event *)
(* new state, with PC incremented & r := log (l, 15 * |ptrty|) *)
(Ir.SmallStep.update_reg_and_incrpc md st r (Ir.ptr (Ir.plog l 15))).
Proof.
intros.
inv HINST; try congruence.
unfold Ir.SmallStep.inst_det_step in HNEXT. rewrite HCUR in HNEXT.
inv HNEXT. des_ifs.
unfold Ir.SmallStep.gep. rewrite HSZ. simpl.
assert (Ir.SmallStep.twos_compl_add 10 5 Ir.PTRSZ = 15).
{ unfold Ir.SmallStep.twos_compl_add.
simpl. unfold Ir.SmallStep.twos_compl. rewrite Ir.PTRSZ_def.
reflexivity. }
rewrite H. ss.
Qed.
(****************************************************
gep phy(10), 5 is phy(15)
****************************************************)
Theorem gep_physical1:
forall st md r ptrty op1 opidx sr I cid
(HOP1:Ir.Config.get_val st op1 = Some (Ir.ptr (Ir.pphy 10 I cid)))
(HOP2:Ir.Config.get_val st opidx = Some (Ir.num 5))
(HCUR:Ir.Config.cur_inst md st = Some (Ir.Inst.igep r (Ir.ptrty ptrty) op1 opidx false))
(HSZ:Ir.ty_bytesz ptrty = 1)
(HINST:Ir.SmallStep.inst_step md st sr),
sr = Ir.SmallStep.sr_success
Ir.e_none (* no event *)
(* new state, with PC incremented & r := phy (l, 15 * |ptrty|) *)
(Ir.SmallStep.update_reg_and_incrpc md st r (Ir.ptr (Ir.pphy 15 I cid))).
Proof.
intros.
inv HINST; try congruence.
unfold Ir.SmallStep.inst_det_step in HNEXT. rewrite HCUR in HNEXT.
inv HNEXT. des_ifs.
unfold Ir.SmallStep.gep. rewrite HSZ. simpl.
assert (Ir.SmallStep.twos_compl_add 10 5 Ir.PTRSZ = 15).
{ unfold Ir.SmallStep.twos_compl_add.
simpl. unfold Ir.SmallStep.twos_compl. rewrite Ir.PTRSZ_def.
reflexivity. }
rewrite H. ss.
Qed.
(****************************************************
gep inbounds log(l, 10), 5 is poison
if l's size is less than 10.
****************************************************)
Theorem gep_inb_logical1:
forall st md r ptrty op1 opidx sr l mb
(HOP1:Ir.Config.get_val st op1 = Some (Ir.ptr (Ir.plog l 10)))
(HOP2:Ir.Config.get_val st opidx = Some (Ir.num 5))
(HCUR:Ir.Config.cur_inst md st = Some (Ir.Inst.igep r (Ir.ptrty ptrty) op1 opidx true))
(HSZ:Ir.ty_bytesz ptrty = 1)
(HMB:Ir.Memory.get (Ir.Config.m st) l = Some mb)
(HN: Ir.MemBlock.n mb < 10 * Ir.ty_bytesz ptrty)
(HINST:Ir.SmallStep.inst_step md st sr),
sr = Ir.SmallStep.sr_success
Ir.e_none (* no event *)
(* new state, with PC incremented & r := poison *)
(Ir.SmallStep.update_reg_and_incrpc md st r Ir.poison).
Proof.
intros.
inv HINST; try congruence.
unfold Ir.SmallStep.inst_det_step in HNEXT. rewrite HCUR in HNEXT.
inv HNEXT. des_ifs.
unfold Ir.SmallStep.gep. rewrite HMB. rewrite HSZ in *. simpl.
assert (Ir.SmallStep.twos_compl_add 10 5 Ir.PTRSZ = 15).
{ unfold Ir.SmallStep.twos_compl_add.
simpl. unfold Ir.SmallStep.twos_compl. rewrite Ir.PTRSZ_def.
reflexivity. }
rewrite H. unfold Ir.MemBlock.inbounds.
rewrite Nat.lt_nge in HN.
rewrite <- Nat.leb_nle in HN.
replace (10 * 1) with 10 in HN. rewrite HN. ss. ss.
Qed.
(****************************************************
gep inbounds pphy(l, i), j is poison
if j*Ir.ty_bytesz is positive &
i+(j*Ir.ty_bytesz) is not smaller than MEMSZ.
****************************************************)
Theorem gep_inb_physical1:
forall st md r ptrty op1 opidx sr i I cid j
(HOP1:Ir.Config.get_val st op1 = Some (Ir.ptr (Ir.pphy i I cid)))
(HOP2:Ir.Config.get_val st opidx = Some (Ir.num j))
(HCUR:Ir.Config.cur_inst md st = Some (Ir.Inst.igep r (Ir.ptrty ptrty) op1 opidx true))
(HN: Ir.MEMSZ <= i + j * Ir.ty_bytesz ptrty)
(HPOS: j * Ir.ty_bytesz ptrty < Nat.shiftl 1 (Ir.PTRSZ - 1))
(HINST:Ir.SmallStep.inst_step md st sr),
sr = Ir.SmallStep.sr_success
Ir.e_none (* no event *)
(* new state, with PC incremented & r := poison *)
(Ir.SmallStep.update_reg_and_incrpc md st r Ir.poison).
Proof.
intros.
inv HINST; try congruence.
unfold Ir.SmallStep.inst_det_step in HNEXT. rewrite HCUR in HNEXT.
inv HNEXT. des_ifs.
unfold Ir.SmallStep.gep.
rewrite <- Nat.ltb_lt in HPOS. rewrite HPOS.
rewrite Nat.le_ngt in HN.
rewrite <- Nat.ltb_nlt in HN.
rewrite HN. ss.
Qed.
(****************************************************
gep inbounds pphy(l, i), j is poison
if j*Ir.ty_bytesz is negative &
i+(j*Ir.ty_bytesz) is smaller than Ir.MEMSZ
(which means that, i-|j*Ir.ty_bytesz| is less than
0)
****************************************************)
Theorem gep_inb_physical2:
forall st md r ptrty op1 opidx sr i I cid j
(HOP1:Ir.Config.get_val st op1 = Some (Ir.ptr (Ir.pphy i I cid)))
(HOP2:Ir.Config.get_val st opidx = Some (Ir.num j))
(HCUR:Ir.Config.cur_inst md st = Some (Ir.Inst.igep r (Ir.ptrty ptrty) op1 opidx true))
(HN: i + j * Ir.ty_bytesz ptrty < Ir.MEMSZ)
(HNEG: Nat.shiftl 1 (Ir.PTRSZ - 1) <= j * Ir.ty_bytesz ptrty)
(HINST:Ir.SmallStep.inst_step md st sr),
sr = Ir.SmallStep.sr_success
Ir.e_none (* no event *)
(* new state, with PC incremented & r := poison *)
(Ir.SmallStep.update_reg_and_incrpc md st r Ir.poison).
Proof.
intros.
inv HINST; try congruence.
unfold Ir.SmallStep.inst_det_step in HNEXT. rewrite HCUR in HNEXT.
inv HNEXT. des_ifs.
unfold Ir.SmallStep.gep.
rewrite Nat.le_ngt in HNEG.
rewrite <- Nat.ltb_nlt in HNEG. rewrite HNEG.
rewrite Nat.lt_nge in HN.
rewrite <- Nat.leb_nle in HN.
rewrite HN. ss.
Qed.
End GetElementPtr.
Module IcmpEq.
(****************************************************
icmp eq 1, 2 is always false.
****************************************************)
Theorem icmp_eq_int_false:
forall st r rty op1 op2 sr md
(HOP1:Ir.Config.get_val st op1 = Some (Ir.num 1))
(HOP2:Ir.Config.get_val st op2 = Some (Ir.num 2))
(HCUR:Ir.Config.cur_inst md st = Some (Ir.Inst.iicmp_eq r rty op1 op2))
(HINST:Ir.SmallStep.inst_step md st sr),
sr = Ir.SmallStep.sr_success
Ir.e_none (* no event *)
(* new state, with PC incremented & r := false *)
(Ir.SmallStep.update_reg_and_incrpc md st r (Ir.num 0)).
Proof.
intros.
inv HINST; try congruence.
unfold Ir.SmallStep.inst_det_step in HNEXT.
rewrite HCUR, HOP1, HOP2 in HNEXT.
inv HNEXT.
reflexivity.
Qed.
(****************************************************
icmp eq 15, 15 is always true.
****************************************************)
Theorem icmp_eq_int_true:
forall st r rty op1 op2 sr md
(HOP1:Ir.Config.get_val st op1 = Some (Ir.num 15))
(HOP2:Ir.Config.get_val st op2 = Some (Ir.num 15))
(HCUR:Ir.Config.cur_inst md st = Some (Ir.Inst.iicmp_eq r rty op1 op2))
(HINST:Ir.SmallStep.inst_step md st sr),
sr = Ir.SmallStep.sr_success
Ir.e_none (* no event *)
(* new state, with PC incremented & r := true *)
(Ir.SmallStep.update_reg_and_incrpc md st r (Ir.num 1)).
Proof.
intros.
inv HINST; try congruence.
unfold Ir.SmallStep.inst_det_step in HNEXT.
rewrite HCUR in HNEXT.
rewrite HOP1, HOP2 in HNEXT. inv HNEXT.
reflexivity.
Qed.
(****************************************************
icmp eq poison, _ is poison.
****************************************************)
Theorem icmp_eq_poison:
forall st r rty op1 op2 sr md
(HOP1:Ir.Config.get_val st op1 = Some (Ir.poison))
(HCUR:Ir.Config.cur_inst md st = Some (Ir.Inst.iicmp_eq r rty op1 op2))
(HINST:Ir.SmallStep.inst_step md st sr),
sr = Ir.SmallStep.sr_success
Ir.e_none (* no event *)
(* new state, with PC incremented & r := poison *)
(Ir.SmallStep.update_reg_and_incrpc md st r (Ir.poison)).
Proof.
intros.
inv HINST; try congruence.
unfold Ir.SmallStep.inst_det_step in HNEXT.
rewrite HCUR in HNEXT.
rewrite HOP1 in HNEXT. inv HNEXT.
reflexivity.
Qed.
(****************************************************
If ptr1 = log(l, o1) & ptr2 = log(l, o2),
icmp eq ptr1, ptr2 is equivalent to o1 == o2.
****************************************************)
Theorem icmp_eq_ptr_sameblock:
forall st r rty op1 op2 sr md l o1 o2 mb
(HOP1:Ir.Config.get_val st op1 = Some (Ir.ptr (Ir.plog l o1)))
(HOP2:Ir.Config.get_val st op2 = Some (Ir.ptr (Ir.plog l o2)))
(HCUR:Ir.Config.cur_inst md st = Some (Ir.Inst.iicmp_eq r rty op1 op2))
(HBLK:Ir.Memory.get (Ir.Config.m st) l = Some mb)
(HINST:Ir.SmallStep.inst_step md st sr),
sr = Ir.SmallStep.sr_success
Ir.e_none (* no event *)
(* new state, with PC incremented & r := o1 == o2 *)
(Ir.SmallStep.update_reg_and_incrpc md st r
(Ir.SmallStep.to_num (Nat.eqb o1 o2))).
Proof.
intros.
inv HINST; try congruence.
- unfold Ir.SmallStep.inst_det_step in HNEXT.
rewrite HCUR in HNEXT.
rewrite HOP1, HOP2 in HNEXT.
unfold Ir.SmallStep.icmp_eq_ptr in HNEXT.
rewrite PeanoNat.Nat.eqb_refl in HNEXT.
inv HNEXT.
reflexivity.
- (* icmp cannot be nondeteministic. *)
rewrite HCUR in HCUR0.
inv HCUR0.
rewrite HOP1 in HOP0. inv HOP0.
rewrite HOP2 in HOP3. inv HOP3.
unfold Ir.SmallStep.icmp_eq_ptr_nondet_cond in HNONDET.
rewrite HBLK in HNONDET.
rewrite PeanoNat.Nat.eqb_refl in HNONDET.
inv HNONDET.
Qed.
(****************************************************
If ptr1 = log(l1, o1) & ptr2 = log(l2, o2)
& l1 != l2
& o1 and o2 are smaller than block sizes
& two blocks are still alive,
icmp eq ptr1, ptr2 is false.
****************************************************)
Theorem icmp_eq_ptr_diffblock_false1:
forall st r rty op1 op2 sr md l1 l2 o1 o2 mb1 mb2 beg1 beg2
(HOP1:Ir.Config.get_val st op1 = Some (Ir.ptr (Ir.plog l1 o1)))
(HOP2:Ir.Config.get_val st op2 = Some (Ir.ptr (Ir.plog l2 o2)))
(HDIFFBLK:l1 <> l2) (* different memory blocks *)
(HCUR:Ir.Config.cur_inst md st = Some (Ir.Inst.iicmp_eq r rty op1 op2))
(HBLK1:Ir.Memory.get (Ir.Config.m st) l1 = Some mb1)
(HBLK2:Ir.Memory.get (Ir.Config.m st) l2 = Some mb2)
(HOFS1:o1 < Ir.MemBlock.n mb1) (* offset is smaller than block size *)
(HOFS2:o2 < Ir.MemBlock.n mb2)
(HALIVE1:Ir.MemBlock.r mb1 = (beg1, None)) (* the blocks are alive *)
(HALIVE2:Ir.MemBlock.r mb2 = (beg2, None))
(HINST:Ir.SmallStep.inst_step md st sr),
sr = Ir.SmallStep.sr_success
Ir.e_none (* no event *)
(* new state, with PC incremented & r := false *)
(Ir.SmallStep.update_reg_and_incrpc md st r (Ir.num 0)).
Proof.
intros.
assert (HNEQ1: o1 <> Ir.MemBlock.n mb1). omega.
rewrite <- PeanoNat.Nat.eqb_neq in HNEQ1.
assert (HNEQ2: o2 <> Ir.MemBlock.n mb2). omega.
rewrite <- PeanoNat.Nat.eqb_neq in HNEQ2.
apply PeanoNat.Nat.lt_asymm in HOFS1.
apply PeanoNat.Nat.lt_asymm in HOFS2.
rewrite <- PeanoNat.Nat.ltb_nlt in HOFS1, HOFS2.
rewrite <- PeanoNat.Nat.eqb_neq in HDIFFBLK.
assert (HNONDET:Ir.SmallStep.icmp_eq_ptr_nondet_cond (Ir.plog l1 o1)
(Ir.plog l2 o2) (Ir.Config.m st) = false).
{ unfold Ir.SmallStep.icmp_eq_ptr_nondet_cond.
rewrite HBLK1, HBLK2, HDIFFBLK.
rewrite HOFS1, HOFS2, HNEQ1, HNEQ2.
simpl.
rewrite orb_false_r.
rewrite andb_false_r.
simpl.
rewrite HALIVE1, HALIVE2. reflexivity.
}
inv HINST; try congruence.
- unfold Ir.SmallStep.inst_det_step in HNEXT.
rewrite HCUR in HNEXT.
rewrite HOP1, HOP2 in HNEXT.
unfold Ir.SmallStep.icmp_eq_ptr in HNEXT.
rewrite HDIFFBLK in HNEXT.
rewrite HNONDET in HNEXT. inv HNEXT.
reflexivity.
Qed.
(****************************************************
If ptr1 = log(l1, o1) & ptr2 = log(l2, o2)
& l1 != l2
& o1 = block size & 0 < o2 < block size
& two blocks are still alive,
icmp eq ptr1, ptr2 is false.
****************************************************)
Theorem icmp_eq_ptr_diffblock_false2:
forall st r rty op1 op2 sr md l1 l2 o1 o2 mb1 mb2 beg1 beg2
(HOP1:Ir.Config.get_val st op1 = Some (Ir.ptr (Ir.plog l1 o1)))
(HOP2:Ir.Config.get_val st op2 = Some (Ir.ptr (Ir.plog l2 o2)))
(HDIFFBLK:l1 <> l2) (* different memory blocks *)
(HCUR:Ir.Config.cur_inst md st = Some (Ir.Inst.iicmp_eq r rty op1 op2))
(HBLK1:Ir.Memory.get (Ir.Config.m st) l1 = Some mb1)
(HBLK2:Ir.Memory.get (Ir.Config.m st) l2 = Some mb2)
(HOFS1:o1 = Ir.MemBlock.n mb1) (* o1 is the block size *)
(HOFS2:0 < o2 < Ir.MemBlock.n mb2) (* 0 < o2 < block size *)
(HALIVE1:Ir.MemBlock.r mb1 = (beg1, None)) (* the blocks are alive *)
(HALIVE2:Ir.MemBlock.r mb2 = (beg2, None))
(HINST:Ir.SmallStep.inst_step md st sr),
sr = Ir.SmallStep.sr_success
Ir.e_none (* no event *)
(* new state, with PC incremented & r := false *)
(Ir.SmallStep.update_reg_and_incrpc md st r (Ir.num 0)).
Proof.
intros.
assert (HNEQ2: o2 <> Ir.MemBlock.n mb2). omega.
rewrite <- PeanoNat.Nat.eqb_neq in HNEQ2.
apply <- PeanoNat.Nat.eqb_eq in HOFS1.
destruct HOFS2 as [HOFS21 HOFS22].
apply Nat.lt_neq in HOFS21.
apply not_eq_sym in HOFS21.
rewrite <- Nat.eqb_neq in HOFS21.
apply PeanoNat.Nat.lt_asymm in HOFS22.
rewrite <- PeanoNat.Nat.ltb_nlt in HOFS22.
rewrite <- PeanoNat.Nat.eqb_neq in HDIFFBLK.
assert (HNONDET:Ir.SmallStep.icmp_eq_ptr_nondet_cond (Ir.plog l1 o1)
(Ir.plog l2 o2) (Ir.Config.m st) = false).
{ unfold Ir.SmallStep.icmp_eq_ptr_nondet_cond.
rewrite HBLK1, HBLK2, HDIFFBLK.
rewrite HOFS1, HOFS21, HOFS22, HNEQ2.
simpl.
rewrite orb_false_r.
rewrite andb_false_r.
simpl.
rewrite HALIVE1, HALIVE2.
rewrite PeanoNat.Nat.eqb_eq in HOFS1.
rewrite HOFS1.
rewrite Nat.ltb_irrefl.
reflexivity.
}
inv HINST; try congruence.
- unfold Ir.SmallStep.inst_det_step in HNEXT.
rewrite HCUR in HNEXT.
rewrite HOP1, HOP2 in HNEXT.
unfold Ir.SmallStep.icmp_eq_ptr in HNEXT.
rewrite HDIFFBLK in HNEXT.
rewrite HNONDET in HNEXT. inv HNEXT.
reflexivity.
Qed.
(****************************************************
If ptr1 = log(l1, o1) & ptr2 = log(l2, o2)
& l1 != l2
& two blocks have disjoint life times,
icmp eq ptr1, ptr2 yields nondeterminstic result.
****************************************************)
Theorem icmp_eq_ptr_diffblock_nondet1:
forall st r rty op1 op2 sr md l1 l2 o1 o2 mb1 mb2 beg1 beg2 end1 end2
(HOP1:Ir.Config.get_val st op1 = Some (Ir.ptr (Ir.plog l1 o1)))
(HOP2:Ir.Config.get_val st op2 = Some (Ir.ptr (Ir.plog l2 o2)))
(HDIFFBLK:l1 <> l2) (* different memory blocks *)
(HCUR:Ir.Config.cur_inst md st = Some (Ir.Inst.iicmp_eq r rty op1 op2))
(HBLK1:Ir.Memory.get (Ir.Config.m st) l1 = Some mb1)
(HBLK2:Ir.Memory.get (Ir.Config.m st) l2 = Some mb2)
(HALIVE1:Ir.MemBlock.r mb1 = (beg1, Some end1)) (* blocks' life times *)
(HALIVE2:Ir.MemBlock.r mb2 = (beg2, Some end2))
(HDISJ: end1 <= beg2 \/ end2 <= beg1) (* life times are disjoint. *)
(HINST:Ir.SmallStep.inst_step md st sr)
(HNONEMPTYSTACK:Ir.Stack.empty (Ir.Config.s st)=false), (* register file should exist *)
exists sr2,
Ir.SmallStep.inst_step md st sr2 /\
sr <> sr2.
Proof.
intros.
rewrite <- PeanoNat.Nat.eqb_neq in HDIFFBLK.
assert (HNONDET:Ir.SmallStep.icmp_eq_ptr_nondet_cond (Ir.plog l1 o1)
(Ir.plog l2 o2) (Ir.Config.m st) = true).
{ unfold Ir.SmallStep.icmp_eq_ptr_nondet_cond.
rewrite HBLK1, HBLK2, HDIFFBLK.
simpl.
rewrite HALIVE1, HALIVE2.
inv HDISJ; rewrite <- PeanoNat.Nat.leb_le in H; rewrite H.
simpl. repeat (rewrite orb_true_r). reflexivity.
simpl. repeat (rewrite orb_true_r). reflexivity.
}
inv HINST; try congruence.
- (* it's not deterministic. *)
unfold Ir.SmallStep.inst_det_step in HNEXT.
rewrite HCUR in HNEXT.
rewrite HOP1, HOP2 in HNEXT.
unfold Ir.SmallStep.icmp_eq_ptr in HNEXT.
rewrite HDIFFBLK in HNEXT.
rewrite HNONDET in HNEXT. congruence.
- destruct res.
{
exists (Ir.SmallStep.sr_success Ir.e_none
(Ir.SmallStep.update_reg_and_incrpc md st r0 (Ir.num 1))).
split.
{ eapply Ir.SmallStep.s_icmp_eq_nondet.
eassumption. reflexivity. eassumption. eassumption.
eassumption. }
{
assert ((Ir.SmallStep.update_reg_and_incrpc md st r0 (Ir.num 0)) <>
(Ir.SmallStep.update_reg_and_incrpc md st r0 (Ir.num 1))).
{ apply Ir.SmallStep.update_reg_and_incrpc_diffval. congruence. assumption. }
congruence.
}
}
{ exists (Ir.SmallStep.sr_success Ir.e_none
(Ir.SmallStep.update_reg_and_incrpc md st r0 (Ir.num 0))).
split.
{ eapply Ir.SmallStep.s_icmp_eq_nondet.
eassumption. reflexivity. eassumption. eassumption.
eassumption. }
{ assert ((Ir.SmallStep.update_reg_and_incrpc md st r0 (Ir.num (S res))) <>
(Ir.SmallStep.update_reg_and_incrpc md st r0 (Ir.num 0))).
{ apply Ir.SmallStep.update_reg_and_incrpc_diffval. congruence. assumption. }
congruence.
}
}
Qed.
(****************************************************
If ptr1 = log(l1, o1) & ptr2 = log(l2, o2)
& l1 != l2
& o1 = 0 & o2 = block size,
icmp eq ptr1, ptr2 yields nondeterminstic result.
****************************************************)
Theorem icmp_eq_ptr_diffblock_nondet2:
forall st r rty op1 op2 sr md l1 l2 o2 mb1 mb2
(HWF:Ir.Config.wf md st) (* The input state is well-formed *)
(HOP1:Ir.Config.get_val st op1 = Some (Ir.ptr (Ir.plog l1 0)))
(HOP2:Ir.Config.get_val st op2 = Some (Ir.ptr (Ir.plog l2 o2)))
(HDIFFBLK:l1 <> l2) (* different memory blocks *)
(HCUR:Ir.Config.cur_inst md st = Some (Ir.Inst.iicmp_eq r rty op1 op2))
(HBLK1:Ir.Memory.get (Ir.Config.m st) l1 = Some mb1)
(HBLK2:Ir.Memory.get (Ir.Config.m st) l2 = Some mb2)
(HOFS2:o2 = Ir.MemBlock.n mb2) (* o2 is the block size *)
(HINST:Ir.SmallStep.inst_step md st sr)
(HNONEMPTYSTACK:Ir.Stack.empty (Ir.Config.s st)=false), (* register file should exist *)
exists sr2,
Ir.SmallStep.inst_step md st sr2 /\
sr <> sr2.
Proof.
intros.
assert (HNEQ1: 0 <> Ir.MemBlock.n mb1).
{ (* Prove this from well-formedness of block mb1. *)
inv HWF. inv wf_m.
symmetry in HBLK1.
apply Ir.Memory.get_In with (blks := Ir.Memory.blocks (Ir.Config.m st)) in HBLK1.
apply wf_blocks in HBLK1.
inv HBLK1.
unfold no_empty_range in wf_poslen.
unfold Ir.MemBlock.P_ranges in wf_poslen.
destruct (Ir.MemBlock.n mb1) eqn:HN.
{ induction (Ir.MemBlock.P mb1).
{ simpl in wf_twin. inv wf_twin. }
{ simpl in wf_poslen. congruence. }
}
{ omega. }
{ reflexivity. }
}
rewrite <- PeanoNat.Nat.eqb_neq in HNEQ1.
rewrite <- PeanoNat.Nat.eqb_eq in HOFS2.
rewrite <- PeanoNat.Nat.eqb_neq in HDIFFBLK.
assert (HNONDET:Ir.SmallStep.icmp_eq_ptr_nondet_cond (Ir.plog l1 0)
(Ir.plog l2 o2) (Ir.Config.m st) = true).
{ unfold Ir.SmallStep.icmp_eq_ptr_nondet_cond.
rewrite HBLK1, HBLK2, HDIFFBLK.
rewrite HOFS2, HNEQ1.
simpl.
reflexivity.
}
inv HINST; try congruence.
- (* it's not deterministic. *)
unfold Ir.SmallStep.inst_det_step in HNEXT.
rewrite HCUR in HNEXT.
rewrite HOP1, HOP2 in HNEXT.
unfold Ir.SmallStep.icmp_eq_ptr in HNEXT.
rewrite HDIFFBLK in HNEXT.
rewrite HNONDET in HNEXT. congruence.
- destruct res.
{
exists (Ir.SmallStep.sr_success Ir.e_none
(Ir.SmallStep.update_reg_and_incrpc md st r0 (Ir.num 1))).
split.
{ eapply Ir.SmallStep.s_icmp_eq_nondet.
eassumption. reflexivity. eassumption. eassumption.
eassumption. }
{ assert ((Ir.SmallStep.update_reg_and_incrpc md st r0 (Ir.num 0)) <>
(Ir.SmallStep.update_reg_and_incrpc md st r0 (Ir.num 1))).
{ apply Ir.SmallStep.update_reg_and_incrpc_diffval. congruence. assumption. }
congruence.
}
}
{ exists (Ir.SmallStep.sr_success Ir.e_none
(Ir.SmallStep.update_reg_and_incrpc md st r0 (Ir.num 0))).
split.
{ eapply Ir.SmallStep.s_icmp_eq_nondet.
eassumption. reflexivity. eassumption. eassumption.
eassumption. }
{ assert ((Ir.SmallStep.update_reg_and_incrpc md st r0 (Ir.num (S res))) <>
(Ir.SmallStep.update_reg_and_incrpc md st r0 (Ir.num 0))).
{ apply Ir.SmallStep.update_reg_and_incrpc_diffval. congruence. assumption. }
congruence.
}
}
Qed.
(****************************************************
If ptr1 = log(l1, o1) & ptr2 = log(l2, o2)
& l1 != l2
& o1 = block size & o2 = 0,
icmp eq ptr1, ptr2 yields nondeterminstic result.
****************************************************)
Theorem icmp_eq_ptr_diffblock_nondet3:
forall st r rty op1 op2 sr md l1 l2 o1 mb1 mb2
(HWF:Ir.Config.wf md st) (* The input state is well-formed *)
(HOP1:Ir.Config.get_val st op1 = Some (Ir.ptr (Ir.plog l1 o1)))
(HOP2:Ir.Config.get_val st op2 = Some (Ir.ptr (Ir.plog l2 0)))
(HDIFFBLK:l1 <> l2) (* different memory blocks *)
(HCUR:Ir.Config.cur_inst md st = Some (Ir.Inst.iicmp_eq r rty op1 op2))
(HBLK1:Ir.Memory.get (Ir.Config.m st) l1 = Some mb1)
(HBLK2:Ir.Memory.get (Ir.Config.m st) l2 = Some mb2)
(HOFS1:o1 = Ir.MemBlock.n mb1) (* o2 is the block size *)
(HINST:Ir.SmallStep.inst_step md st sr)
(HNONEMPTYSTACK:Ir.Stack.empty (Ir.Config.s st)=false), (* register file should exist *)
exists sr2,
Ir.SmallStep.inst_step md st sr2 /\
sr <> sr2.
Proof.
intros.
assert (HNEQ2: 0 <> Ir.MemBlock.n mb2).
{ (* Prove this from well-formedness of block mb1. *)
inv HWF. inv wf_m.
symmetry in HBLK2.
apply Ir.Memory.get_In with (blks := Ir.Memory.blocks (Ir.Config.m st)) in HBLK2.
apply wf_blocks in HBLK2.
inv HBLK2.
unfold no_empty_range in wf_poslen.
unfold Ir.MemBlock.P_ranges in wf_poslen.
destruct (Ir.MemBlock.n mb2) eqn:HN.
{ induction (Ir.MemBlock.P mb2).
{ simpl in wf_twin. inv wf_twin. }
{ simpl in wf_poslen. congruence. }
}
{ omega. }
{ reflexivity. }
}
rewrite <- PeanoNat.Nat.eqb_neq in HNEQ2.
rewrite <- PeanoNat.Nat.eqb_eq in HOFS1.
rewrite <- PeanoNat.Nat.eqb_neq in HDIFFBLK.
assert (HNONDET:Ir.SmallStep.icmp_eq_ptr_nondet_cond (Ir.plog l1 o1)
(Ir.plog l2 0) (Ir.Config.m st) = true).
{ unfold Ir.SmallStep.icmp_eq_ptr_nondet_cond.
rewrite HBLK1, HBLK2, HDIFFBLK.
rewrite HOFS1, HNEQ2.
simpl.
reflexivity.
}
inv HINST; try congruence.
- (* it's not deterministic. *)
unfold Ir.SmallStep.inst_det_step in HNEXT.
rewrite HCUR in HNEXT.
rewrite HOP1, HOP2 in HNEXT.
unfold Ir.SmallStep.icmp_eq_ptr in HNEXT.
rewrite HDIFFBLK in HNEXT.
rewrite HNONDET in HNEXT. congruence.
- destruct res.
{
exists (Ir.SmallStep.sr_success Ir.e_none
(Ir.SmallStep.update_reg_and_incrpc md st r0 (Ir.num 1))).
split.
{ eapply Ir.SmallStep.s_icmp_eq_nondet.
eassumption. reflexivity. eassumption. eassumption.
eassumption. }
{ assert ((Ir.SmallStep.update_reg_and_incrpc md st r0 (Ir.num 0)) <>
(Ir.SmallStep.update_reg_and_incrpc md st r0 (Ir.num 1))).
{ apply Ir.SmallStep.update_reg_and_incrpc_diffval. congruence. assumption. }
congruence.
}
}
{ exists (Ir.SmallStep.sr_success Ir.e_none
(Ir.SmallStep.update_reg_and_incrpc md st r0 (Ir.num 0))).
split.
{ eapply Ir.SmallStep.s_icmp_eq_nondet.
eassumption. reflexivity. eassumption. eassumption.
eassumption. }
{ assert ((Ir.SmallStep.update_reg_and_incrpc md st r0 (Ir.num (S res))) <>
(Ir.SmallStep.update_reg_and_incrpc md st r0 (Ir.num 0))).
{ apply Ir.SmallStep.update_reg_and_incrpc_diffval. congruence. assumption. }
congruence.
}
}
Qed.
End IcmpEq.
Module IcmpUle.
(****************************************************
icmp ule 1, 2 is always true.
****************************************************)
Theorem icmp_ule_int_true1:
forall st r rty op1 op2 sr md
(HOP1:Ir.Config.get_val st op1 = Some (Ir.num 1))
(HOP2:Ir.Config.get_val st op2 = Some (Ir.num 2))
(HCUR:Ir.Config.cur_inst md st = Some (Ir.Inst.iicmp_ule r rty op1 op2))
(HINST:Ir.SmallStep.inst_step md st sr),
sr = Ir.SmallStep.sr_success
Ir.e_none (* no event *)
(* new state, with PC incremented & r := true *)
(Ir.SmallStep.update_reg_and_incrpc md st r (Ir.num 1)).
Proof.
intros.
inv HINST; try congruence.
unfold Ir.SmallStep.inst_det_step in HNEXT.
rewrite HCUR in HNEXT.
rewrite HOP1, HOP2 in HNEXT. inv HNEXT.
reflexivity.
Qed.
(****************************************************
icmp ule 15, 15 is always true.
****************************************************)
Theorem icmp_ule_int_true2:
forall st r rty op1 op2 sr md
(HOP1:Ir.Config.get_val st op1 = Some (Ir.num 15))
(HOP2:Ir.Config.get_val st op2 = Some (Ir.num 15))
(HCUR:Ir.Config.cur_inst md st = Some (Ir.Inst.iicmp_ule r rty op1 op2))
(HINST:Ir.SmallStep.inst_step md st sr),
sr = Ir.SmallStep.sr_success
Ir.e_none (* no event *)
(* new state, with PC incremented & r := true *)
(Ir.SmallStep.update_reg_and_incrpc md st r (Ir.num 1)).
Proof.
intros.
inv HINST; try congruence.
unfold Ir.SmallStep.inst_det_step in HNEXT.
rewrite HCUR in HNEXT.
rewrite HOP1, HOP2 in HNEXT. inv HNEXT.
reflexivity.
Qed.
(****************************************************
icmp ule 15, 14 is always false.
****************************************************)
Theorem icmp_ule_int_false:
forall st r rty op1 op2 sr md
(HOP1:Ir.Config.get_val st op1 = Some (Ir.num 15))
(HOP2:Ir.Config.get_val st op2 = Some (Ir.num 14))
(HCUR:Ir.Config.cur_inst md st = Some (Ir.Inst.iicmp_ule r rty op1 op2))
(HINST:Ir.SmallStep.inst_step md st sr),
sr = Ir.SmallStep.sr_success
Ir.e_none (* no event *)
(* new state, with PC incremented & r := false *)
(Ir.SmallStep.update_reg_and_incrpc md st r (Ir.num 0)).
Proof.
intros.
inv HINST; try congruence.
unfold Ir.SmallStep.inst_det_step in HNEXT.
rewrite HCUR in HNEXT.
rewrite HOP1, HOP2 in HNEXT. inv HNEXT.
reflexivity.
Qed.
(****************************************************
icmp ule poison, _ is always poison.
****************************************************)
Theorem icmp_ule_poison:
forall st r rty op1 op2 sr md
(HOP1:Ir.Config.get_val st op1 = Some (Ir.poison))
(HCUR:Ir.Config.cur_inst md st = Some (Ir.Inst.iicmp_ule r rty op1 op2))
(HINST:Ir.SmallStep.inst_step md st sr),
sr = Ir.SmallStep.sr_success
Ir.e_none (* no event *)
(* new state, with PC incremented & r := poison *)
(Ir.SmallStep.update_reg_and_incrpc md st r (Ir.poison)).
Proof.
intros.
inv HINST; try congruence.
unfold Ir.SmallStep.inst_det_step in HNEXT.
rewrite HCUR in HNEXT.
rewrite HOP1 in HNEXT. inv HNEXT.
reflexivity.
Qed.
(****************************************************
If ptr1 = log(l, o1) & ptr2 = log(l, o2),
& o1 <= block size & o2 <= block size,
icmp ule ptr1, ptr2 is equivalent to o1 <= o2.
****************************************************)
Theorem icmp_ule_ptr_sameblock_det:
forall st r rty op1 op2 sr md l o1 o2 mb
(HOP1:Ir.Config.get_val st op1 = Some (Ir.ptr (Ir.plog l o1)))
(HOP2:Ir.Config.get_val st op2 = Some (Ir.ptr (Ir.plog l o2)))
(HCUR:Ir.Config.cur_inst md st = Some (Ir.Inst.iicmp_ule r rty op1 op2))
(HBLK:Ir.Memory.get (Ir.Config.m st) l = Some mb)
(HOFS1:o1 <= Ir.MemBlock.n mb)
(HOFS2:o2 <= Ir.MemBlock.n mb)
(HINST:Ir.SmallStep.inst_step md st sr),
sr = Ir.SmallStep.sr_success
Ir.e_none (* no event *)
(* new state, with PC incremented & r := o1 <= o2 *)
(Ir.SmallStep.update_reg_and_incrpc md st r
(Ir.SmallStep.to_num (Nat.leb o1 o2))).
Proof.
intros.
assert (HNONDET: Ir.SmallStep.icmp_ule_ptr_nondet_cond (Ir.plog l o1)
(Ir.plog l o2) (Ir.Config.m st) = false).
{ unfold Ir.SmallStep.icmp_ule_ptr_nondet_cond.
rewrite PeanoNat.Nat.eqb_refl.
rewrite HBLK.
rewrite <- PeanoNat.Nat.leb_le in HOFS1, HOFS2.
rewrite HOFS1. rewrite HOFS2. reflexivity. }
inv HINST; try congruence.
- unfold Ir.SmallStep.inst_det_step in HNEXT.
rewrite HCUR in HNEXT.
rewrite HOP1, HOP2 in HNEXT.
unfold Ir.SmallStep.icmp_ule_ptr in HNEXT.
rewrite HNONDET in HNEXT.
rewrite HBLK in HNEXT.
inv HNEXT.
reflexivity.
Qed.
(****************************************************
If ptr1 = log(l, o1) & ptr2 = log(l, o2),
& (block size < o1 \/ block size < o2),
icmp ule ptr1, ptr2 yields nondeterministic value.
****************************************************)
Theorem icmp_ule_ptr_sameblock_nondet:
forall st r rty op1 op2 sr md l o1 o2 mb
(HOP1:Ir.Config.get_val st op1 = Some (Ir.ptr (Ir.plog l o1)))
(HOP2:Ir.Config.get_val st op2 = Some (Ir.ptr (Ir.plog l o2)))
(HCUR:Ir.Config.cur_inst md st = Some (Ir.Inst.iicmp_ule r rty op1 op2))
(HBLK:Ir.Memory.get (Ir.Config.m st) l = Some mb)
(HOFS:Ir.MemBlock.n mb < o1 \/ Ir.MemBlock.n mb < o2)
(HNONEMPTYSTACK:Ir.Stack.empty (Ir.Config.s st)=false) (* register file should exist *)
(HINST:Ir.SmallStep.inst_step md st sr),
exists sr',
Ir.SmallStep.inst_step md st sr' /\
sr' <> sr.
Proof.
intros.
assert (HNONDET: Ir.SmallStep.icmp_ule_ptr_nondet_cond (Ir.plog l o1)
(Ir.plog l o2) (Ir.Config.m st) = true).
{ unfold Ir.SmallStep.icmp_ule_ptr_nondet_cond.
rewrite PeanoNat.Nat.eqb_refl.
rewrite HBLK.
repeat (rewrite Nat.lt_nge in HOFS).
repeat (rewrite <- Nat.leb_nle in HOFS).
destruct HOFS.
{ rewrite H. reflexivity. }
{ rewrite H. simpl. rewrite orb_true_r. reflexivity. }
}
inv HINST; try congruence.
- unfold Ir.SmallStep.inst_det_step in HNEXT.
rewrite HCUR in HNEXT.
rewrite HOP1, HOP2 in HNEXT.
unfold Ir.SmallStep.icmp_ule_ptr in HNEXT.
rewrite HNONDET in HNEXT.
inv HNEXT.
- rewrite HCUR in HCUR0.
inv HCUR0.
destruct res.
{ exists (Ir.SmallStep.sr_success Ir.e_none
(Ir.SmallStep.update_reg_and_incrpc md st r (Ir.num 1))).
split.
{ eapply Ir.SmallStep.s_icmp_ule_nondet.
rewrite HCUR. reflexivity. reflexivity. eassumption.
eassumption. eassumption. }
{ assert ((Ir.SmallStep.update_reg_and_incrpc md st r (Ir.num 1)) <>
(Ir.SmallStep.update_reg_and_incrpc md st r (Ir.num 0))).
{ apply Ir.SmallStep.update_reg_and_incrpc_diffval.
congruence. assumption. }
congruence.
}
}
{ exists (Ir.SmallStep.sr_success Ir.e_none
(Ir.SmallStep.update_reg_and_incrpc md st r (Ir.num 0))).
split.
{ eapply Ir.SmallStep.s_icmp_ule_nondet.
rewrite HCUR. reflexivity. reflexivity. eassumption.
eassumption. eassumption. }
{ assert ((Ir.SmallStep.update_reg_and_incrpc md st r (Ir.num 0)) <>
(Ir.SmallStep.update_reg_and_incrpc md st r (Ir.num (S res)))).
{ apply Ir.SmallStep.update_reg_and_incrpc_diffval.
congruence. assumption. }
congruence.
}
}
Qed.
(****************************************************
If ptr1 = log(l1, o1) & ptr2 = log(l2, o2),
icmp ule ptr1, ptr2 yields nondeterministic value.
****************************************************)
Theorem icmp_ule_ptr_diffblock_nondet:
forall st r rty op1 op2 sr md l1 l2 o1 o2
(HOP1:Ir.Config.get_val st op1 = Some (Ir.ptr (Ir.plog l1 o1)))
(HOP2:Ir.Config.get_val st op2 = Some (Ir.ptr (Ir.plog l2 o2)))
(HDIFFBLK:l1 <> l2)
(HCUR:Ir.Config.cur_inst md st = Some (Ir.Inst.iicmp_ule r rty op1 op2))
(HNONEMPTYSTACK:Ir.Stack.empty (Ir.Config.s st)=false) (* register file should exist *)
(HINST:Ir.SmallStep.inst_step md st sr),
exists sr',
Ir.SmallStep.inst_step md st sr' /\
sr' <> sr.
Proof.
intros.
assert (HNONDET: Ir.SmallStep.icmp_ule_ptr_nondet_cond (Ir.plog l1 o1)
(Ir.plog l2 o2) (Ir.Config.m st) = true).
{ unfold Ir.SmallStep.icmp_ule_ptr_nondet_cond.
rewrite <- PeanoNat.Nat.eqb_neq in HDIFFBLK.
rewrite HDIFFBLK. reflexivity.
}
inv HINST; try congruence.
- unfold Ir.SmallStep.inst_det_step in HNEXT.
rewrite HCUR in HNEXT.
rewrite HOP1, HOP2 in HNEXT.
unfold Ir.SmallStep.icmp_ule_ptr in HNEXT.
rewrite HNONDET in HNEXT.
inv HNEXT.
- rewrite HCUR in HCUR0.
inv HCUR0.
destruct res.
{ exists (Ir.SmallStep.sr_success Ir.e_none
(Ir.SmallStep.update_reg_and_incrpc md st r (Ir.num 1))).
split.
{ eapply Ir.SmallStep.s_icmp_ule_nondet.
rewrite HCUR. reflexivity. reflexivity. eassumption.
eassumption. eassumption. }
{ assert ((Ir.SmallStep.update_reg_and_incrpc md st r (Ir.num 1)) <>
(Ir.SmallStep.update_reg_and_incrpc md st r (Ir.num 0))).
{ apply Ir.SmallStep.update_reg_and_incrpc_diffval.
congruence. assumption. }
congruence.
}
}
{ exists (Ir.SmallStep.sr_success Ir.e_none
(Ir.SmallStep.update_reg_and_incrpc md st r (Ir.num 0))).
split.
{ eapply Ir.SmallStep.s_icmp_ule_nondet.
rewrite HCUR. reflexivity. reflexivity. eassumption.
eassumption. eassumption. }
{ assert ((Ir.SmallStep.update_reg_and_incrpc md st r (Ir.num 0)) <>
(Ir.SmallStep.update_reg_and_incrpc md st r (Ir.num (S res)))).
{ apply Ir.SmallStep.update_reg_and_incrpc_diffval.
congruence. assumption. }
congruence.
}
}
Qed.
End IcmpUle.
Module PSub.
(****************************************************
psub poison, _ is always poison.
****************************************************)
Theorem psub_poison:
forall st r rty pty op1 op2 sr md
(HOP1:Ir.Config.get_val st op1 = Some (Ir.poison))
(HCUR:Ir.Config.cur_inst md st = Some (Ir.Inst.ipsub r rty pty op1 op2))
(HINST:Ir.SmallStep.inst_step md st sr),
sr = Ir.SmallStep.sr_success
Ir.e_none (* no event *)
(* new state, with PC incremented & r := poison *)
(Ir.SmallStep.update_reg_and_incrpc md st r (Ir.poison)).
Proof.
intros.
inv HINST; try congruence.
unfold Ir.SmallStep.inst_det_step in HNEXT.