proposition: Lemma For_computes_to_nil : forall {heading} P, forall ens, computes_to (For (QueryResultComp (heading := heading) ens (fun tup => Where (P tup) Return tup))) [] -> forall x, ens x -> ~ (P (indexedRawTuple x)).
proof: Proof. unfold refine, decides, Count, Query_For, QueryResultComp; intros **. computes_to_inv. symmetry in H'; apply Permutation_nil in H'; subst. apply UnIndexedEnsembleListEquivalence_eqv in H; destruct_ex; intuition; subst. apply H2 in H0. apply in_split in H0. destruct H0 as [ x1_before [ x1_after _eq ] ]; subst. rewrite map_map in H'0. eapply (@FlattenCompList.flatten_CompList_nil _ P); unfold boxed_option; eauto; intuition. Qed.
imports: Fiat.QueryStructure.Specification.Representation.QueryStructureNotations Fiat.QueryStructure.Specification.Operations.Query Coq.Lists.List Coq.Arith.Compare_dec Coq.Bool.Bool Coq.Strings.String Fiat.Common.BoolFacts Fiat.Common.List.PermutationFacts Fiat.Common.List.ListMorphisms Fiat.QueryStructure.Specification.Operations.FlattenCompList Fiat.Common.Ensembles.EnsembleListEquivalence Fiat.QueryStructure.Implementation.Operations.General.QueryRefinements Fiat.Common.IterateBoundedIndex Fiat.Common.List.ListFacts Fiat.Common.LogicFacts Fiat.Common.DecideableEnsembles Fiat.Computation.Refinements.Iterate_Decide_Comp Fiat.Computation.Refinements.General Fiat.QueryStructure.Specification.Constraints.tupleAgree Fiat.QueryStructure.Specification.Operations.Mutate