proposition: Corollary TrieBag_enumerateOK' : forall l st1 search_term, (forall (k : X.t) (subtrie : Trie), InA (PX.eqke (elt:=Trie)) (k, subtrie) l -> TrieOK subtrie (st1 ++ [k])) -> Permutation (List.filter (TrieBag_bfind_matcher (Some st1, search_term)) (flatten (List.map benumerate (fold_left (fun (a : list (BagType)) (p : key * Trie) => (Trie_enumerate (snd p)) ++ a) l [ ])))) [].
proof: Proof. intros. rewrite <- (@TrieBag_enumerateOK1 l st1 search_term [ ] H) by intuition. remember (@nil BagType); remember (@nil (X.t * BagType)). assert (List.map snd l1 = l0) by (subst; eauto). generalize l1 l0 H0; clear; induction l; simpl; intros. rewrite <- map_map with (f := snd). setoid_rewrite H0. reflexivity. rewrite <- IHl; eauto. rewrite map_app, map_map, map_id; simpl. setoid_rewrite H0; reflexivity. Qed.
imports: Fiat.Common.Coq__8_4__8_5__Compat Fiat.QueryStructure.Implementation.DataStructures.Bags.BagsInterface Fiat.QueryStructure.Implementation.DataStructures.Bags.BagsProperties Coq.FSets.FMapInterface Coq.FSets.FMapFacts Coq.FSets.FMapAVL Coq.ZArith.ZArith Fiat.Common Fiat.Common.List.ListFacts Fiat.Common.List.FlattenList Fiat.Common.SetEqProperties Fiat.Common.FMapExtensions Fiat.Common.List.PermutationFacts Fiat.QueryStructure.Specification.SearchTerms.ListPrefix