繁体   English   中英

我一直坚持使用 MApp 来抽取引理

[英]I have been stuck on MApp for pumping lemma

我一直在尝试解决 Coq 中的 Pumping lemma。

我在第三个子目标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.

我在MApp上的证明如下。

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 *)

我现在被困在案例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

我尝试用案例H: length s1>=pumping_constant -> re1 length s1=pumping_constant re1 \/ length s1>pumping_constatn re1解决它。

它把我带到了某个地方,但正确的案例很难破解。 我应该如何进行?

直观地说(我没有安装特定的库),我将从length s1 >= pumping_constant re1的案例分析开始

  • 如果成立,则可以应用 IH1,然后将 append s2应用于s1分解的第三个元素的右侧。
  • 如果length s1 < pumping_constant re1并且s1 ++ s2足够长,那么length s2 >= pumping_constant re2 ,并且可以应用IH2 ,然后 append s1s2分解的第一个元素的左侧。

(待验证)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM