proposition: Lemma Forall_image A B : forall (f : A -> B) l, Forall (fun y => exists x, y = f x) l <-> exists l', l = map f l'.
proof: Proof. intros f l; induction l as [|a l IHl]; split; intros HF. - exists nil; reflexivity. - constructor. - apply Forall_cons_iff in HF as [[x ->] [l' ->] %IHl]. now exists (x :: l'). - destruct HF as [l' Heq]. symmetry in Heq; apply map_eq_cons in Heq. destruct Heq as (x & tl & ? & ? & ?); subst. constructor. + now exists x. + now apply IHl; exists tl. Qed.
imports: PeanoNat