Commit 6ad31c1 1 parent fdb1ba1 commit 6ad31c1 Copy full SHA for 6ad31c1
File tree 2 files changed +53
-0
lines changed
2 files changed +53
-0
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,9 @@ def char {α: Type} (x : α): Lang α :=
23
23
def pred {α: Type } (p : α -> Prop ): Lang α :=
24
24
fun xs => ∃ x, xs = [x] /\ p x
25
25
26
+ def any {α: Type }: Lang α :=
27
+ fun xs => ∃ x, xs = [x]
28
+
26
29
-- onlyif is used as an and to make derive char not require an if statement
27
30
-- (derive (char c) a) w <-> (onlyif (a = c) emptystr)
28
31
def onlyif {α: Type } (cond : Prop ) (R : Lang α) : Lang α :=
@@ -924,3 +927,23 @@ theorem simp_star_emptyset_is_emptystr {α: Type}:
924
927
intro h
925
928
rw [h]
926
929
exact star.zero
930
+
931
+ theorem simp_star_any_is_universal {α: Type }:
932
+ star (@any α) = @universal α := by
933
+ funext xs
934
+ simp only [universal, eq_iff_iff]
935
+ apply Iff.intro
936
+ case mp =>
937
+ intro h
938
+ exact True.intro
939
+ case mpr =>
940
+ intro h
941
+ induction xs with
942
+ | nil =>
943
+ exact star.zero
944
+ | cons x xs ih =>
945
+ apply star.more x [] xs
946
+ · simp only [singleton_append]
947
+ · unfold any
948
+ exists x
949
+ · exact ih
Original file line number Diff line number Diff line change @@ -346,6 +346,36 @@ theorem orToList_is_orFromList (x: Regex α):
346
346
rw [orFromList_cons_NonEmptyList_is_or]
347
347
rw [ih2]
348
348
349
+ theorem simp_pred_any_is_any :
350
+ denote (Regex.pred (@Predicate.mkAny α o)) = Language.any := by
351
+ unfold denote
352
+ unfold Predicate.mkAny
353
+ unfold Predicate.func
354
+ simp only
355
+ unfold mkAnyPredFunc
356
+ unfold Language.pred
357
+ unfold Language.any
358
+ funext xs
359
+ simp only [and_true]
360
+
361
+ theorem simp_star_pred_any_is_universal [o: Ord α]:
362
+ denote (Regex.star (Regex.pred (@Predicate.mkAny α o))) = Language.universal := by
363
+ unfold denote
364
+ rw [simp_pred_any_is_any]
365
+ exact Language.simp_star_any_is_universal
366
+
367
+ theorem simp_or_universal_r_is_universal [Ord α] (x: Regex α):
368
+ denote (Regex.or x (Regex.star (Regex.pred Predicate.mkAny))) = Language.universal := by
369
+ nth_rewrite 1 [denote]
370
+ rw [simp_star_pred_any_is_universal]
371
+ rw [Language.simp_or_universal_r_is_universal]
372
+
373
+ theorem simp_or_universal_l_is_universal [Ord α] (x: Regex α):
374
+ denote (Regex.or (Regex.star (Regex.pred Predicate.mkAny)) x) = Language.universal := by
375
+ nth_rewrite 1 [denote]
376
+ rw [simp_star_pred_any_is_universal]
377
+ rw [Language.simp_or_universal_l_is_universal]
378
+
349
379
-- 1. If x or y is emptyset then return the other (Language.simp_or_emptyset_r_is_l and Language.simp_or_emptyset_l_is_r)
350
380
-- 2. If x or y is star (any) then return star (any) (Language.simp_or_universal_r_is_universal and Language.simp_or_universal_l_is_universal)
351
381
-- 3. Get the lists of ors using orToList (Language.simp_or_assoc)
You can’t perform that action at this time.
0 commit comments