Skip to content

Commit e83d246

Browse files
Work on interactEqualsModelScore
1 parent 9ef8c53 commit e83d246

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

theories/DisjointSetUnionCode2.v

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1345,7 +1345,7 @@ Proof.
13451345
rewrite dropWithinLoopLiftToWithinLoop. unfold retrieve at 1. rewrite -!bindAssoc pushDispatch2 unfoldInvoke_S_Retrieve. case_decide as hu; [| reflexivity]. exfalso. rewrite lengthConvert pathCompressPreservesLength in hu. lia.
13461346
Qed.
13471347

1348-
Lemma outOfBoundsInteraction1B (a b : Z) (hLA : Z.le 0 a) (hUA : Z.lt a 256) (hOOB : Z.le 100 b) (hUB : Z.lt b 256) (dsu : list Slot) (hL : length dsu = 100) (hL1 : Z.to_nat (dsuLeafCount dsu) = length dsu) (y1 : noIllegalIndices dsu) (y2 : withoutCyclesN dsu (length dsu)) : invokeContract (repeat 1%Z 20) (repeat 0%Z 20) 0%Z state state [a; b] 1 = Some ([], state).
1348+
Lemma outOfBoundsInteraction1B (a b : Z) (hLA : Z.le 0 a) (hUA : Z.lt a 256) (hOOB : Z.le 100 b) (hUB : Z.lt b 256) : invokeContract (repeat 1%Z 20) (repeat 0%Z 20) 0%Z state state [a; b] 1 = Some ([], state).
13491349
Proof.
13501350
destruct (decide (Z.le 100 a)) as [hy | hy].
13511351
{ apply outOfBoundsInteraction1A; lia. }
@@ -1494,4 +1494,17 @@ Qed.
14941494

14951495
Lemma interactEqualsModelScore (x : list (Z * Z)) (hN : forall a b, In (a, b) x -> Z.le 0 a /\ Z.lt a 256 /\ Z.le 0 b /\ Z.lt b 256) : interact state x = modelScore x.
14961496
Proof.
1497+
induction x as [| head tail IH]. { easy. }
1498+
destruct head as [a b].
1499+
pose proof hN a b ltac:(left; reflexivity) as [h1 [h2 [h3 h4]]].
1500+
rewrite (ltac:(intros; simpl; reflexivity) : forall state, interact state ((a, b) :: tail) = _).
1501+
fold (repeat 1%Z 20). fold (repeat 0%Z 20).
1502+
unfold modelScore. rewrite ((ltac:(easy) : forall a b, a :: b = [a] ++ b) (a, b)) map_app (ltac:(easy) : map (λ _0 : Z * Z, let (_1, _2) := _0 in (Z.to_nat _1, Z.to_nat _2))
1503+
[(a, b)] = [(Z.to_nat a, Z.to_nat b)]) -(ltac:(easy) : forall a b, a :: b = [a] ++ b). rewrite (ltac:(simpl; reflexivity) : dsuFromInteractions _ (_ :: _) = _).
1504+
case_decide as hv; rewrite repeat_length in hv.
1505+
- rewrite firstInteraction; try lia. admit.
1506+
- destruct (ltac:(lia) : Z.le 100 a \/ Z.le 100 b) as [h5 | h5].
1507+
+ rewrite outOfBoundsInteraction1A; try assumption. apply IH. intros m1 m2 m3. apply hN. right. exact m3.
1508+
+ rewrite outOfBoundsInteraction1B; try assumption. apply IH. intros m1 m2 m3. apply hN. right. exact m3.
1509+
(* can't directly do induction here, must use an auxiliary lemma *)
14971510
Admitted.

0 commit comments

Comments
 (0)