proposition: Lemma char_at_matches_is_char offset len str P (Hlen : offset + len <= length str) : (Nat.eqb len 1 && char_at_matches offset str P)%bool = true <-> (exists ch, P ch /\ substring offset len str ~= [ch])%string_like.
proof: Proof. rewrite char_at_matches_is_char_no_ex by assumption. destruct (get offset str) as [ch|] eqn:Heq. { split; intro H; [ exists ch; assumption | ]. destruct H as [ch' H]. assert (ch = ch'); [ | subst; assumption ]. destruct H as [H0 H1]. apply take_n_1_singleton in H1. apply get_0 in H1. rewrite get_drop in Heq. congruence. } { split; [ intros [] | intros [ch [H0 H1]] ]. rewrite get_drop in Heq. apply no_first_char_empty in Heq. rewrite drop_length in Heq. apply length_singleton in H1. assert (len = 0) by omega; subst. rewrite substring_length, <- Nat.sub_min_distr_r, Nat.add_sub, Nat.min_0_r in H1. omega. } Qed.
imports: Fiat.Common.Coq__8_4__8_5__Compat Coq.ZArith.ZArith Fiat.Common Fiat.Common.List.Operations Fiat.Common.List.ListFacts Fiat.Common.Le Fiat.Common.Tactics.SetoidSubst Fiat.Common.Tactics.IsClosed Fiat.Parsers.StringLike.Core Fiat.Common.UIP