Skip to content

Commit 16788c8

Browse files
prove orToList_is_orFromList
1 parent c028877 commit 16788c8

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

Katydid/Regex/SmartRegex.lean

+22-2
Original file line numberDiff line numberDiff line change
@@ -319,12 +319,32 @@ def orFromList (xs: NonEmptyList (Regex α)): Regex α :=
319319
| NonEmptyList.mk x1 (x2::xs) =>
320320
Regex.or x1 (orFromList (NonEmptyList.mk x2 xs))
321321

322+
private theorem orFromList_is_or_nonEmptyList (x1 x2: Regex α) (xs: List (Regex α)):
323+
orFromList (NonEmptyList.mk x1 (x2 :: xs)) = Regex.or x1 (orFromList (NonEmptyList.mk x2 xs )) := by
324+
simp only [orFromList]
325+
326+
private theorem orFromList_cons_NonEmptyList_is_or (x1: Regex α) (xs2: NonEmptyList (Regex α)):
327+
orFromList (NonEmptyList.cons x1 xs2) = Regex.or x1 (orFromList xs2) := by
328+
unfold orFromList
329+
unfold NonEmptyList.cons
330+
simp only [Regex.or.injEq, true_and]
331+
cases xs2 with
332+
| mk head tail =>
333+
cases tail with
334+
| nil =>
335+
simp
336+
unfold orFromList
337+
rfl
338+
| cons t1 t2 =>
339+
simp
340+
rw [orFromList_is_or_nonEmptyList]
341+
322342
theorem orToList_is_orFromList (x: Regex α):
323343
orFromList (orToList x) = x := by
324344
induction x <;> (try simp only [orToList, orFromList])
325345
· case or x1 x2 ih1 ih2 =>
326-
-- TODO
327-
sorry
346+
rw [orFromList_cons_NonEmptyList_is_or]
347+
rw [ih2]
328348

329349
-- 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)
330350
-- 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)

0 commit comments

Comments
 (0)