@@ -30,16 +30,16 @@ def and {α: Type} (P : Lang α) (Q : Lang α) : Lang α :=
30
30
fun w => P w /\ Q w
31
31
32
32
def concat {α: Type } (P : Lang α) (Q : Lang α) : Lang α :=
33
- fun (w : List α) =>
34
- ∃ (x : List α) (y : List α), P x /\ Q y /\ w = (x ++ y )
33
+ fun (xs : List α) =>
34
+ ∃ (ys : List α) (zs : List α), P ys /\ Q zs /\ xs = (ys ++ zs )
35
35
36
36
inductive All {α: Type } (P : α -> Prop ) : (List α -> Prop ) where
37
37
| nil : All P []
38
38
| cons : ∀ {x xs} (_px : P x) (_pxs : All P xs), All P (x :: xs)
39
39
40
40
def star {α: Type } (R : Lang α) : Lang α :=
41
- fun (w : List α) =>
42
- ∃ (ws : List (List α)), All R ws /\ w = (List.flatten ws )
41
+ fun (xs : List α) =>
42
+ ∃ (xss : List (List α)), All R xss /\ xs = (List.flatten xss )
43
43
44
44
-- attribute [ simp ] allows these definitions to be unfolded when using the simp tactic.
45
45
attribute [simp] universal emptyset emptystr char onlyif or and concat star
@@ -116,6 +116,14 @@ def null_emptyset {α: Type}:
116
116
@null α emptyset = False :=
117
117
rfl
118
118
119
+ def null_iff_emptyset {α: Type }:
120
+ @null α emptyset <-> False := by
121
+ rw [null_emptyset]
122
+
123
+ def not_null_if_emptyset {α: Type }:
124
+ @null α emptyset -> False :=
125
+ null_iff_emptyset.mp
126
+
119
127
def null_universal {α: Type }:
120
128
@null α universal = True :=
121
129
rfl
@@ -126,6 +134,10 @@ def null_iff_emptystr {α: Type}:
126
134
(fun _ => True.intro)
127
135
(fun _ => rfl)
128
136
137
+ def null_if_emptystr {α: Type }:
138
+ @null α emptystr :=
139
+ rfl
140
+
129
141
def null_emptystr {α: Type }:
130
142
@null α emptystr = True := by
131
143
rw [null_iff_emptystr]
@@ -134,6 +146,10 @@ def null_iff_char {α: Type} {c: α}:
134
146
null (char c) <-> False :=
135
147
Iff.intro nofun nofun
136
148
149
+ def not_null_if_char {α: Type } {c: α}:
150
+ null (char c) -> False :=
151
+ nofun
152
+
137
153
def null_char {α: Type } {c: α}:
138
154
null (char c) = False := by
139
155
rw [null_iff_char]
@@ -142,6 +158,10 @@ def null_or {α: Type} {P Q: Lang α}:
142
158
null (or P Q) = ((null P) \/ (null Q)) :=
143
159
rfl
144
160
161
+ def null_iff_or {α: Type } {P Q: Lang α}:
162
+ null (or P Q) <-> ((null P) \/ (null Q)) := by
163
+ rw [null_or]
164
+
145
165
def null_and {α: Type } {P Q: Lang α}:
146
166
null (and P Q) = ((null P) /\ (null Q)) :=
147
167
rfl
@@ -170,6 +190,14 @@ def null_star {α: Type} {P: Lang α}:
170
190
· intro l hl
171
191
cases hl
172
192
193
+ def null_iff_star {α: Type } {P: Lang α}:
194
+ null (star P) <-> True := by
195
+ rw [null_star]
196
+
197
+ def null_if_star {α: Type } {P: Lang α}:
198
+ null (star P) :=
199
+ null_iff_star.mpr True.intro
200
+
173
201
def derive_emptyset {α: Type } {a: α}:
174
202
(derive emptyset a) = emptyset :=
175
203
rfl
@@ -293,17 +321,17 @@ inductive starplus {α: Type} (R: Lang α): Lang α where
293
321
-> starplus R qs
294
322
-> starplus R w
295
323
296
- theorem star_is_starplus : ∀ {α: Type } (R: Lang α) (w : List α),
297
- star R w -> starplus R w := by
298
- intro α R w
324
+ theorem star_is_starplus : ∀ {α: Type } (R: Lang α) (xs : List α),
325
+ star R xs -> starplus R xs := by
326
+ intro α R xs
299
327
unfold star
300
328
intro s
301
329
match s with
302
330
| Exists.intro ws (And.intro sl sr) =>
303
331
clear s
304
332
rw [sr]
305
333
clear sr
306
- clear w
334
+ clear xs
307
335
induction ws with
308
336
| nil =>
309
337
simp
@@ -319,6 +347,37 @@ theorem star_is_starplus: ∀ {α: Type} (R: Lang α) (w: List α),
319
347
· assumption
320
348
· assumption
321
349
350
+ theorem starplus_is_star : ∀ {α: Type } (R: Lang α) (xs: List α),
351
+ starplus R xs -> star R xs := by
352
+ intro α R xs
353
+ intro hs
354
+ induction xs with
355
+ | nil =>
356
+ simp
357
+ exists []
358
+ apply And.intro ?_ (by simp)
359
+ apply All.nil
360
+ | cons x' xs' ih =>
361
+ cases hs with
362
+ | more ps qs _ xxspsqs Rps sRqs =>
363
+ unfold star
364
+ have hxs := list_split_cons (x' :: xs')
365
+ cases hxs with
366
+ | inl h =>
367
+ contradiction
368
+ | inr h =>
369
+ cases h with
370
+ | intro x h =>
371
+ cases h with
372
+ | intro xs h =>
373
+ cases h with
374
+ | intro ys h =>
375
+ rw [h]
376
+ have hys := list_split_flatten ys
377
+ cases hys with
378
+ | intro yss hyss =>
379
+ sorry
380
+
322
381
inductive starcons {α: Type } (R: Lang α): Lang α where
323
382
| zero: starcons R []
324
383
| more: ∀ (p: α) (ps qs w: List α),
@@ -395,8 +454,8 @@ theorem star_is_starcons: ∀ {α: Type} (R: Lang α) (xs: List α),
395
454
| intro h2l h2r =>
396
455
sorry
397
456
398
- def derive_iff_star {α: Type } {a : α} {P : Lang α} {w : List α}:
399
- (derive (star P) a) w <-> (concat (derive P a ) (star P )) w := by
457
+ def derive_iff_star {α: Type } {x : α} {R : Lang α} {xs : List α}:
458
+ (derive (star R) x) xs <-> (concat (derive R x ) (star R )) xs := by
400
459
refine Iff.intro ?toFun ?invFun
401
460
case toFun =>
402
461
sorry
0 commit comments