Commit 532a9ed0 authored by Robbert Krebbers's avatar Robbert Krebbers

Some clean up to Hai's commit.

parent 6f1a23cb
...@@ -187,35 +187,30 @@ Section curry_uncurry. ...@@ -187,35 +187,30 @@ Section curry_uncurry.
apply map_eq; intros [i j]. by rewrite lookup_gmap_curry, lookup_gmap_uncurry. apply map_eq; intros [i j]. by rewrite lookup_gmap_curry, lookup_gmap_uncurry.
Qed. Qed.
Lemma gmap_uncurry_nonempty (m : gmap (K1 * K2) A): Lemma gmap_uncurry_non_empty (m : gmap (K1 * K2) A) i x :
i x, gmap_uncurry m !! i = Some x x . gmap_uncurry m !! i = Some x x .
Proof. Proof.
apply (map_fold_ind (λ mr m, i x, mr !! i = Some x x )); [done|]. intros Hm ->. revert m Hm.
intros [i j] x m12 mr Hij IH i' x'. apply (map_fold_ind (λ mr _, mr !! i = Some False)); [done|].
destruct (decide (i = i')) as [->|]; intros [i' j] x m mr ??. destruct (decide (i = i')) as [->|].
[rewrite lookup_partial_alter - rewrite lookup_partial_alter. intros [= []%insert_non_empty].
|rewrite lookup_partial_alter_ne; [apply IH|done]]. - by rewrite lookup_partial_alter_ne by done.
inversion 1. apply insert_non_empty.
Qed. Qed.
Lemma gmap_uncurry_curry_nonempty (m : gmap K1 (gmap K2 A)) Lemma gmap_uncurry_curry_non_empty (m : gmap K1 (gmap K2 A)) :
(NE: i x, m !! i = Some x x ) : ( i x, m !! i = Some x x )
gmap_uncurry (gmap_curry m) = m. gmap_uncurry (gmap_curry m) = m.
Proof. Proof.
apply map_eq; intros i. destruct (m !! i) as [x'|] eqn:Eqx'. intros Hne. apply map_eq; intros i. destruct (m !! i) as [m2|] eqn:Hm.
- destruct (gmap_uncurry (gmap_curry m) !! i) as [x2|] eqn:Eq2. - destruct (gmap_uncurry (gmap_curry m) !! i) as [m2'|] eqn:Hcurry.
+ f_equal. apply map_eq. intros j. + f_equal. apply map_eq. intros j.
assert (Eq3: x' !! j = (m !! i : option (gmap _ _)) = (!! j)). trans ((gmap_uncurry (gmap_curry m) !! i : option (gmap _ _)) = (!! j)).
{ by rewrite Eqx'. } { by rewrite Hcurry. }
assert (Eq4: x2 !! j = ( by rewrite lookup_gmap_uncurry, lookup_gmap_curry, Hm.
gmap_uncurry (gmap_curry m) !! i : option (gmap _ _)) = (!! j)). + rewrite lookup_gmap_uncurry_None in Hcurry.
{ by rewrite Eq2. } exfalso; apply (Hne i m2), map_eq; [done|intros j].
by rewrite Eq3, <- lookup_gmap_curry, Eq4, lookup_gmap_uncurry. by rewrite lookup_empty, <-(Hcurry j), lookup_gmap_curry, Hm.
+ revert Eq2. rewrite lookup_gmap_uncurry_None. - apply lookup_gmap_uncurry_None; intros j. by rewrite lookup_gmap_curry, Hm.
setoid_rewrite lookup_gmap_curry. rewrite Eqx'.
intros Eq2. exfalso. apply (NE _ _ Eqx'), map_eq, Eq2.
- apply lookup_gmap_uncurry_None.
intros j. by rewrite lookup_gmap_curry, Eqx'.
Qed. Qed.
End curry_uncurry. End curry_uncurry.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment