changeset 92:41392e5acbf5

Finish automating regexp
author Adam Chlipala <adamc@hcoop.net>
date Tue, 07 Oct 2008 16:08:58 -0400
parents 4a57a4922af5
children a08e82c646a5
files src/MoreDep.v
diffstat 1 files changed, 26 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- 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