proposition: Lemma first_index_error_first_index_partial {A} (test : A -> bool) (testo : A -> option bool) (H : forall a v, testo a = Some v -> test a = v) (ls : list A) v (Heq : Operations.List.first_index_partial testo ls = Some v) : Operations.List.first_index_error test ls = v.
proof: Proof. revert dependent v; induction ls as [|x xs IHxs]; simpl in *; intros; [ congruence | ]. destruct (testo x) as [[]|] eqn:H'; simpl in *; [ erewrite H by eassumption.. | ]; simpl; [ congruence | | ]. { destruct (Operations.List.first_index_partial testo xs) as [[]|] eqn:H''; simpl in *; try specialize (IHxs _ eq_refl). { rewrite first_index_helper_first_index_error, IHxs; simpl. apply first_index_error_Some_correct in IHxs. destruct IHxs as [[? [IHxs ?]] ?]. rewrite IHxs; simpl; congruence. } { rewrite first_index_helper_first_index_error, IHxs; simpl; congruence. } { congruence. } } { congruence. } Qed.
imports: Fiat.Common.Coq__8_4__8_5__Compat Coq.ZArith.ZArith Coq.Lists.List Coq.Lists.SetoidList Coq.Bool.Bool Fiat.Common Fiat.Common.List.Operations Fiat.Common.Equality Fiat.Common.List.FlattenList Fiat.Common.LogicFacts