Skip to content

Commit f9cf1ef

Browse files
committed
Init cstar is recognizable
1 parent 2774eb1 commit f9cf1ef

1 file changed

Lines changed: 72 additions & 5 deletions

File tree

TraceTheory/TraceTheory/Ochmanski.lean

Lines changed: 72 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -347,11 +347,10 @@ lemma recognizable_mul {P Q : Set (Trace I)} [DecidableEq α]
347347
exact hy
348348
· exact traceClosure.le_closure
349349
have h_mul_reg : (L_P * L_Q).IsRegular := Language.IsRegular.mul hL_P_reg hL_Q_reg
350-
have h_rank : HasFiniteRank I (L_P * L_Q) := by
351-
use 1
352-
exact concat_closed_rank L_P L_Q hL_P_closed hL_Q_closed
350+
have h_rank : HasFiniteRank I (L_P * L_Q) :=
351+
1, concat_closed_rank L_P L_Q hL_P_closed hL_Q_closed⟩
353352
have h_hash := recognizable_image_of_regular_finite_rank h_mul_reg h_rank
354-
have h_image_eq : ⇑(mk' (I := I)) '' (L_P * L_Q) = P * Q := by
353+
have h_image_eq : mk' (I := I) '' (L_P * L_Q) = P * Q := by
355354
ext t
356355
constructor
357356
· rintro ⟨w, ⟨u, hu, v, hv, rfl⟩, rfl⟩
@@ -361,9 +360,77 @@ lemma recognizable_mul {P Q : Set (Trace I)} [DecidableEq α]
361360
rw [← h_image_eq]
362361
exact h_hash
363362

363+
open Computability in
364+
theorem star_connected_closed_rank {X : Language α}
365+
(hX_closed : IsClosed I X)
366+
(hX_conn : ∀ w ∈ X, IsConnected I ⟦w⟧) :
367+
HasFiniteRank I X∗ := by
368+
sorry
369+
370+
open Computability in
364371
lemma recognizable_cstar {P : Set (Trace I)}
365372
(hP : IsRecognizable P) : IsRecognizable (kstar (connectedComponents P)) := by
366-
sorry
373+
let C := connectedComponents P
374+
let L_C : Language α := ⇑(mk' (I := I)) ⁻¹' C
375+
have hC_recog : IsRecognizable C := sorry -- Requires a lemma that connected components of recognizable sets are recognizable
376+
have hL_C_reg : L_C.IsRegular :=
377+
isRegular_of_recognizable (recognizable_has_recognizablePreImage _ _ hC_recog)
378+
have hL_C_closed : IsClosed I L_C := by
379+
apply le_antisymm
380+
· rintro x ⟨y, hy, heqv⟩
381+
simp only [L_C, Set.mem_preimage] at hy ⊢
382+
have heq : mk' (I := I) y = mk' (I := I) x := Quotient.sound heqv
383+
rw [← heq]
384+
exact hy
385+
· exact traceClosure.le_closure
386+
have hL_C_conn : ∀ w ∈ L_C, IsConnected I ⟦w⟧ := by
387+
intro w hw
388+
simp only [L_C, C, connectedComponents] at hw
389+
rw [Set.preimage_setOf_eq, Set.mem_setOf] at hw
390+
exact hw.left
391+
have h_star_reg : (L_C∗).IsRegular := Language.IsRegular.kstar hL_C_reg
392+
have h_rank : HasFiniteRank I (L_C∗) := star_connected_closed_rank hL_C_closed hL_C_conn
393+
have h_hash := recognizable_image_of_regular_finite_rank h_star_reg h_rank
394+
have h_image_eq : mk' (I := I) '' ((L_C∗) : Language α) = kstar C := by
395+
unfold kstar
396+
ext t
397+
constructor
398+
· rintro ⟨w, ⟨ws, rfl, hws⟩, rfl⟩
399+
use ws.map (mk' (I := I))
400+
constructor
401+
· intro t' ht'
402+
simp only [List.mem_map] at ht'
403+
rcases ht' with ⟨w', hw', rfl⟩
404+
exact hws w' hw'
405+
· induction ws with
406+
| nil => rfl
407+
| cons w' ws' ih =>
408+
simp only [List.flatten_cons, List.map_cons, List.prod_cons]
409+
have h_mul : mk' (I := I) (w' ++ ws'.flatten) =
410+
mk' (I := I) w' * mk' (I := I) ws'.flatten := rfl
411+
simp only [List.mem_cons, forall_eq_or_imp] at hws
412+
rw [h_mul, ih hws.right]
413+
· rintro ⟨ts, hts, rfl⟩
414+
induction ts with
415+
| nil => exact ⟨[], by apply Language.nil_mem_kstar, rfl⟩
416+
| cons t' ts' ih =>
417+
have ht' : t' ∈ C := hts t' (by simp)
418+
have hts' : ∀ x ∈ ts', x ∈ C := fun x hx => hts x (by simp [hx])
419+
rcases ih hts' with ⟨w', hw'_star, hw'_eq⟩
420+
rcases t' with ⟨u⟩
421+
have hu_in_LC : u ∈ L_C := ht'
422+
use u ++ w'
423+
constructor
424+
· rw [Language.mem_kstar] at hw'_star ⊢
425+
rcases hw'_star with ⟨ws', rfl, hws'⟩
426+
use u :: ws'
427+
simp only [List.flatten_cons, List.mem_cons, forall_eq_or_imp, true_and]
428+
exact ⟨hu_in_LC, hws'⟩
429+
· have h_mul : mk' (I := I) (u ++ w') = mk' (I := I) u * mk' (I := I) w' := rfl
430+
rw [h_mul, hw'_eq]
431+
rfl
432+
rw [← h_image_eq]
433+
exact h_hash
367434

368435
/-- Theorem 4.1 (iv) => (i) -/
369436
theorem recognizable_of_cRational [DecidableEq α] (X : RegularExpression α) :

0 commit comments

Comments
 (0)