proposition: Lemma first_index_default_first_index_error {A} (f : A -> bool) default (ls : list A) : first_index_default f default ls = option_rect (fun _ => nat) (fun x => x) default (first_index_error f ls).
proof: Proof. unfold first_index_default. rewrite first_index_helper_first_index_error; simpl. destruct (first_index_error f ls) as [n|] eqn:H; simpl; [ | reflexivity ]. destruct (nth_error ls n) eqn:H'; simpl; [ reflexivity | ]. exfalso. apply first_index_error_Some_correct in H. repeat (destruct_head and; destruct_head ex). 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