proposition: Lemma Permutation_map_enumerate : forall key m, Permutation (Values (snd (partition (KeyBasedPartitioningFunction (list TItem) key) (map benumerate m)))) (Values (map benumerate (snd (partition (KeyBasedPartitioningFunction BagType key) m)))).
proof: Proof. intros; eapply Permutation_InA_cons; eauto using elements_3w. intros; repeat rewrite <- elements_mapsto_iff; split. - intros; pose proof (MapsTo_KeyBasedPartition_snd _ _ _ _ H). rewrite map_mapsto_iff. rewrite partition_iff_2 with (f := KeyBasedPartitioningFunction _ key0) in H; eauto using KeyBasedPartitioningFunction_Proper; intuition. rewrite map_mapsto_iff in H1; destruct H1 as [bag [? In_k] ]; subst; eexists; split; eauto. rewrite partition_iff_2 with (f := KeyBasedPartitioningFunction _ key0); eauto using KeyBasedPartitioningFunction_Proper; intuition. - intros. rewrite map_mapsto_iff in H. destruct H as [bag [? In_k] ]; subst. rewrite partition_iff_2 with (f := KeyBasedPartitioningFunction _ key0) in In_k; eauto using KeyBasedPartitioningFunction_Proper; intuition. rewrite partition_iff_2 with (f := KeyBasedPartitioningFunction _ key0); eauto using KeyBasedPartitioningFunction_Proper; intuition. Qed.
imports: Fiat.QueryStructure.Implementation.DataStructures.Bags.BagsInterface Fiat.QueryStructure.Implementation.DataStructures.Bags.BagsProperties Coq.FSets.FMapInterface Coq.FSets.FMapFacts Coq.Arith.PeanoNat Fiat.Common Fiat.Common.List.ListFacts Fiat.Common.List.FlattenList Fiat.Common.SetEqProperties Fiat.Common.FMapExtensions Fiat.Common.List.PermutationFacts