You need to sign in or sign up before continuing.
Some map_zip/map_zip_with properties.
2 unresolved threads
2 unresolved threads
These are some properties of map_zip_with
that I am using so far.
Perhaps you want me to port the whole thing first, to see what other functions/lemmas will I need?
Merge request reports
Activity
1140 map_zip_with f ∅ ∅ = ∅. 1141 Proof. 1142 unfold map_zip_with. by rewrite merge_empty by done. 1143 Qed. 1144 1145 Lemma map_insert_zip_with {A B C} (f : A → B → C) m1 m2 i x y z : 1146 f y z = x → 1147 <[i:=x]>(map_zip_with f m1 m2) = map_zip_with f (<[i:=y]>m1) (<[i:=z]>m2). 1148 Proof. 1149 intros Hf. unfold map_zip_with. 1150 erewrite insert_merge; [ auto | by compute | by rewrite Hf ]. 1151 Qed. 1152 1153 Lemma map_fmap_zip_with {A' A B' B C} (f : A → B → C) 1154 (g1 : A' → A) (g2 : B' → B) m1 m2 : 1155 map_zip_with f (fmap g1 m1) (fmap g2 m2) = map_zip_with (fun x y => f (g1 x) (g2 y)) m1 m2. I would except there to be three variants for the lemma:
- With an
fmap
in the first argument, i.e.map_zip_with f (g1 <$> m1) m2
- With an
fmap
in the second argument, i.e.map_zip_with f m1 (g <$> m2)
- With an
fmap
on the outside, i.e.g <$> map_zip_with f m1 m2
This lemma should follow from the first two lemmas that I mentioned.
Nitpick, use the
<$>
notation and unicode lambdas.- With an
1157 apply map_eq; intro i. 1158 rewrite ?map_lookup_zip_with. rewrite ?lookup_fmap. 1159 by destruct (m1 !! i), (m2 !! i). 1160 Qed. 1161 1162 Lemma map_zip_with_map_zip {A B C} (f : A → B → C) m1 m2 : 1163 map_zip_with f m1 m2 = curry f <$> map_zip m1 m2. 1164 Proof. 1165 apply map_eq; intro i. 1166 rewrite lookup_fmap; rewrite ?map_lookup_zip_with; rewrite ?lookup_fmap. 1167 by destruct (m1 !! i), (m2 !! i). 1168 Qed. 1169 1170 Lemma map_fmap_zip {A' A B' B} (g1 : A' → A) (g2 : B' → B) m1 m2 : 1171 map_zip (fmap g1 m1) (fmap g2 m2) 1172 = (fun '(x,y) => (g1 x, g2 y)) <$> map_zip m1 m2. @robbertkrebbers What do you think of the changes now?
Please register or sign in to reply