coqlogical-foundations

Cannot focus on a remaining unfocused goal in Coq


I am trying to prove the pumping Lemma (which is one of the exercises of the Logical Foundations book). I thought I had completed the MStarApp case but the interpreter tells me that there are still unfocused goals remaining. Only I can't bring this remaining goal to the front. I tried every bullet level but each time I get [Focus] Wrong bullet: No more goals. I don't know if something is wrong with my proof or if it's a bug in the interpreter. Any help would be much appreciated.

- (* MStarApp *)
    intros.
    destruct s1.
    -- replace ([ ] ++ s2) with s2 in *. apply (IH2 H).
       reflexivity.
    -- pose proof (lt_ge_cases (length (x::s1)) (pumping_constant re)) as [
    Hs1lt | Hs1ge].
      --- exists [ ], (x::s1), s2. repeat split.
        + unfold not. intro. inversion H0.
        + simpl. simpl in Hs1lt. 
          apply n_lt_m__n_le_m in Hs1lt.
          apply Hs1lt.
        + simpl. intro m. 
          apply (napp_star T m (x::s1) s2 re Hmatch1 Hmatch2).
      --- unfold ge in Hs1ge. pose proof (IH1 Hs1ge) as [
        s2' [s3' [s4' [Hxs1Eq [Hs3notEmpty [
        Hlens2's3' Hnapp]]]]]].
        exists s2', s3', (s4' ++ s2). repeat split.
        + rewrite Hxs1Eq. repeat rewrite <- app_assoc.
          reflexivity.
        + assumption.
        + simpl. assumption.
        + intro m. pose proof Hnapp m.
          replace (s2' ++ napp m s3' ++ s4' ++ s2) with 
          ((s2' ++ napp m s3' ++ s4') ++ s2).
          constructor.
          ++ assumption.
          ++ assumption.
          ++ repeat rewrite <- app_assoc. reflexivity.
(* 'There are unfocused goals.' *)

Edit: I don't know if this is relevant, but higher in my proof (in the MApp case) I have an assert whose closing curly bracket is highlighted in an unusual way (in yellow instead of green -- I am using the Coq language support extension in VSCode).

unusual highlighting


Solution

  • You have unfinished business in some of the earlier proof branches. The one you are providing does not have any unfinished goals. You have left unfinished or admited some of the earlier goals. Or probably you didn't finish the assert properly. You need to show that part of the proof if you want help with that.

    This is the proof state where your proof begins, and it is solved by your proof script.

    
    Lemma foo   
    (T: Type)
    (s1 s2: list T)
    (re: reg_exp T)
    (Hmatch1: s1 =~ re)
    (Hmatch2: s2 =~ Star re)
    (IH1: pumping_constant re <= length s1 ->
          exists s2 s3 s4 : list T,
            s1 = s2 ++ s3 ++ s4 /\
            s3 <> [ ] /\
            length s2 + length s3 <= pumping_constant re /\
            (forall m : nat, s2 ++ napp m s3 ++ s4 =~ re))
    (IH2: pumping_constant (Star re) <= length s2 ->
          exists s1 s3 s4 : list T,
            s2 = s1 ++ s3 ++ s4 /\
            s3 <> [ ] /\
            length s1 + length s3 <= pumping_constant (Star re) /\
            (forall m : nat, s1 ++ napp m s3 ++ s4 =~ Star re))
    :
    pumping_constant (Star re) <= length (s1 ++ s2) ->
    exists s0 s3 s4 : list T,
      s1 ++ s2 = s0 ++ s3 ++ s4 /\
      s3 <> [ ] /\
      length s0 + length s3 <= pumping_constant (Star re) /\
      (forall m : nat, s0 ++ napp m s3 ++ s4 =~ Star re)
    .