# HG changeset patch # User Adam Chlipala # Date 1223410138 14400 # Node ID 41392e5acbf563a764db9309338bdf78b8b2582c # Parent 4a57a4922af5a072813dbae0cc3c6d495f2c7af1 Finish automating regexp diff -r 4a57a4922af5 -r 41392e5acbf5 src/MoreDep.v --- a/src/MoreDep.v Tue Oct 07 14:52:15 2008 -0400 +++ b/src/MoreDep.v Tue Oct 07 16:08:58 2008 -0400 @@ -537,8 +537,8 @@ Qed. Lemma substring_suffix_emp : forall s n m, - m > 0 - -> substring n m s = "" + substring n m s = "" + -> m > 0 -> n >= length s. destruct m as [| m]; [crush | intros; apply substring_suffix_emp' with m; assumption]. Qed. @@ -656,11 +656,25 @@ Defined. End dec_star''. + Lemma star_length_contra : forall n, + length s > n + -> n >= length s + -> False. + crush. + Qed. + + Lemma star_length_flip : forall n n', + length s - n <= S n' + -> length s > n + -> length s - n > 0. + crush. + Qed. + + Hint Resolve star_length_contra star_length_flip substring_suffix_emp. + Definition dec_star' (n n' : nat) : length s - n' <= n -> {star P (substring n' (length s - n') s)} + {~star P (substring n' (length s - n') s)}. - About dec_star''. - refine (fix F (n n' : nat) {struct n} : length s - n' <= n -> {star P (substring n' (length s - n') s)} + {~star P (substring n' (length s - n') s)} := @@ -671,16 +685,14 @@ | S n'' => fun _ => le_gt_dec (length s) n' || dec_star'' (n := n') (star P) (fun n0 _ => Reduce (F n'' n0 _)) (length s - n') - end); clear F; crush; eauto. - - apply star_substring_inv in H; crush; eauto. - - assert (n' >= length s); [ | omega]. - apply substring_suffix_emp with (length s - n'); crush. - - assert (S x <= length s - n'); [ omega | ]. - apply _1 in H1. - tauto. + end); clear F; crush; eauto; + match goal with + | [ H : star _ _ |- _ ] => apply star_substring_inv in H; crush; eauto + end; + match goal with + | [ H1 : _ < _ - _, H2 : forall l' : nat, _ <= _ - _ -> _ |- _ ] => + generalize (H2 _ (lt_le_S _ _ H1)); tauto + end. Defined. Definition dec_star : {star P s} + { ~star P s}. @@ -700,8 +712,6 @@ Hint Resolve app_cong. - - Definition matches P (r : regexp P) s : {P s} + { ~P s}. refine (fix F P (r : regexp P) s : {P s} + { ~P s} := match r with