0

I have been trying to solve Pumping lemma in Coq.

I was on the third subgoal, Mapp.

Lemma pumping : forall T (re : reg_exp T) s,
  s =~ re ->
  pumping_constant re <= length s ->
  exists s1 s2 s3,
    s = s1 ++ s2 ++ s3 /\
    s2 <> [] /\
    length s1 + length s2 <= pumping_constant re /\
    forall m, s1 ++ napp m s2 ++ s3 =~ re.

My proof on MApp is as follow.

Proof.
  intros T re s Hmatch.
  induction Hmatch
    as [ | x | s1 re1 s2 re2 Hmatch1 IH1 Hmatch2 IH2
       | s1 re1 re2 Hmatch IH | re1 s2 re2 Hmatch IH
       | re | s1 s2 re Hmatch1 IH1 Hmatch2 IH2 ].
  - (* MEmpty -- omitted *)
  - (* MChar -- omitted *)
  - (* MApp *)
    intros T re s Hmatch.
  induction Hmatch
    as [ | x | s1 re1 s2 re2 Hmatch1 IH1 Hmatch2 IH2
       | s1 re1 re2 Hmatch IH | re1 s2 re2 Hmatch IH
       | re | s1 s2 re Hmatch1 IH1 Hmatch2 IH2 ].
  - (* MEmpty *)
    simpl. intros contra. inversion contra.
  - (* MChar *)
    simpl. intros. inversion H. inversion H1.
  - (* MApp *)
    simpl. rewrite app_length. intros.
    apply add_le_cases in H.
    destruct H as [H|H].
    + (*case pumping_constant re1 <= length s1 ommitted*)
    + apply IH2 in H. destruct H as [ss1 [ss2 [ss3 [H1 [H2 [H3 H4]]]]]].
      exists (s1++ss1), ss2, ss3. split.
      * rewrite H1. rewrite <- app_assoc. reflexivity.
      * split. apply H2.
        split. rewrite app_length.
        assert (Hc: length s1<pumping_constant re1 \/ length s1>=pumping_constant re1).
        apply lt_ge_cases.
        destruct Hc as [Hc|Hc].
        apply le_S in Hc.
        apply Sn_le_Sm__n_le_m in Hc.
        rewrite <- add_assoc.
        apply (Plus.plus_le_compat _ _ _ _ Hc).
        apply H3.
        (* stuck *)

I am now stuck on case Hc: length s1>=pumping_constant re1

Goal:
2 goals
T : Type
s1 : list T
re1 : reg_exp T
s2 : list T
re2 : reg_exp T
Hmatch1 : s1 =~ re1
Hmatch2 : s2 =~ re2
IH1 : pumping_constant re1 <= length s1 ->
      exists s2 s3 s4 : list T,
        s1 = s2 ++ s3 ++ s4 /\
        s3 <> [ ] /\
        length s2 + length s3 <= pumping_constant re1 /\
        (forall m : nat, s2 ++ napp m s3 ++ s4 =~ re1)
IH2 : pumping_constant re2 <= length s2 ->
      exists s1 s3 s4 : list T,
        s2 = s1 ++ s3 ++ s4 /\
        s3 <> [ ] /\
        length s1 + length s3 <= pumping_constant re2 /\
        (forall m : nat, s1 ++ napp m s3 ++ s4 =~ re2)
ss1, ss2, ss3 : list T
H1 : s2 = ss1 ++ ss2 ++ ss3
H2 : ss2 <> [ ]
H3 : length ss1 + length ss2 <= pumping_constant re2
H4 : forall m : nat, ss1 ++ napp m ss2 ++ ss3 =~ re2
Hc : length s1 >= pumping_constant re1
______________________________________(1/2)
length s1 + length ss1 + length ss2 <=
pumping_constant re1 + pumping_constant re2

I tried solving it with cases H: length s1>=pumping_constant -> re1 length s1=pumping_constant re1 \/ length s1>pumping_constatn re1.

It got me somewhere but the right case is tough to crack. How should I proceed?

1 Answers1

0

Intuitively (I didn't install the specific libraries), I would start with a case analysis on length s1 >= pumping_constant re1

  • If it holds, you can apply IH1, then append s2 to the right of the third component of the decomposition of s1.
  • If length s1 < pumping_constant re1 and s1 ++ s2is long enough, then length s2 >= pumping_constant re2, and you can apply IH2, then append s1to the left of the first component of the decomposition of s2.

In the sub-goal you display, I didn't find any hypothesis of the form length s1 + length s2 >= pumping_constant re1 + pumping_constant re2, which IMO helps to solve the case where s1is short.

  • Thank you because you have give me inspiration. I should not destruct `length s1 + length s2 >= pumping_constant re1 + pumping_constant re2` instead I should do an analysis on `length s1>= pumping_constant re1 \/ length s1 < pumping_constant re1`. I have found my solution. Thank you again. – Naqib Zahid Aug 01 '22 at 03:05