2 \ 5h1
\ 6Broadcasting points
\ 5/h1
\ 6
3 Intuitively, a regular expression e must be understood as a pointed expression with a single
4 point in front of it. Since however we only allow points before symbols, we must broadcast
5 this initial point inside e traversing all nullable subexpressions, that essentially corresponds
6 to the ϵ-closure operation on automata. We use the notation •(_) to denote such an operation;
7 its definition is the expected one: let us start discussing an example.
10 Let us broadcast a point inside (a + ϵ)(b*a + b)b. We start working in parallel on the
11 first occurrence of a (where the point stops), and on ϵ that gets traversed. We have hence
12 reached the end of a + ϵ and we must pursue broadcasting inside (b*a + b)b. Again, we work in
13 parallel on the two additive subterms b^*a and b; the first point is allowed to both enter the
14 star, and to traverse it, stopping in front of a; the second point just stops in front of b.
15 No point reached that end of b^*a + b hence no further propagation is possible. In conclusion:
16 •((a + ϵ)(b^*a + b)b) = 〈(•a + ϵ)((•b)^*•a + •b)b, false〉
20 include "tutorial/chapter7.ma".
22 definition lo ≝ λS:DeqSet.λa,b:pre S.〈\fst a + \fst b,\snd a ∨ \snd b〉.
23 notation "a ⊕ b" left associative with precedence 60 for @{'oplus $a $b}.
24 interpretation "oplus" 'oplus a b = (lo ? a b).
26 lemma lo_def: ∀S.∀i1,i2:pitem S.∀b1,b2. 〈i1,b1〉⊕〈i2,b2〉=〈i1+i2,b1∨b2〉.
29 definition pre_concat_r ≝ λS:DeqSet.λi:pitem S.λe:pre S.
30 match e with [ mk_Prod i1 b ⇒ 〈i · i1, b〉].
32 notation "i ◃ e" left associative with precedence 60 for @{'lhd $i $e}.
33 interpretation "pre_concat_r" 'lhd i e = (pre_concat_r ? i e).
35 lemma eq_to_ex_eq: ∀S.∀A,B:word S → Prop.
37 #S #A #B #H >H /2/ qed.
39 lemma sem_pre_concat_r : ∀S,i.∀e:pre S.
40 \sem{i ◃ e} =1 \sem{i} · \sem{|\fst e|} ∪ \sem{e}.
41 #S #i * #i1 #b1 cases b1 [2: @eq_to_ex_eq //]
42 >sem_pre_true >sem_cat >sem_pre_true /2/
45 definition pre_concat_l ≝ λS:DeqSet.λbcast:∀S:DeqSet.pitem S → pre S.λe1:pre S.λi2:pitem S.
47 [ mk_Prod i1 b1 ⇒ match b1 with
48 [ true ⇒ (i1 ◃ (bcast ? i2))
49 | false ⇒ 〈i1 · i2,false〉
53 notation "a ▹ b" left associative with precedence 60 for @{'tril eclose $a $b}.
54 interpretation "item-pre concat" 'tril op a b = (pre_concat_l ? op a b).
56 notation "•" non associative with precedence 60 for @{eclose ?}.
58 let rec eclose (S: DeqSet) (i: pitem S) on i : pre S ≝
62 | ps x ⇒ 〈 `.x, false〉
63 | pp x ⇒ 〈 `.x, false 〉
64 | po i1 i2 ⇒ •i1 ⊕ •i2
66 | pk i ⇒ 〈(\fst (•i))^*,true〉].
68 notation "• x" non associative with precedence 60 for @{'eclose $x}.
69 interpretation "eclose" 'eclose x = (eclose ? x).
71 lemma eclose_plus: ∀S:DeqSet.∀i1,i2:pitem S.
72 •(i1 + i2) = •i1 ⊕ •i2.
75 lemma eclose_dot: ∀S:DeqSet.∀i1,i2:pitem S.
76 •(i1 · i2) = •i1 ▹ i2.
79 lemma eclose_star: ∀S:DeqSet.∀i:pitem S.
80 •i^* = 〈(\fst(•i))^*,true〉.
83 definition lift ≝ λS.λf:pitem S →pre S.λe:pre S.
85 [ mk_Prod i b ⇒ 〈\fst (f i), \snd (f i) ∨ b〉].
87 definition preclose ≝ λS. lift S (eclose S).
88 interpretation "preclose" 'eclose x = (preclose ? x).
91 lemma sem_oplus: ∀S:DeqSet.∀e1,e2:pre S.
92 \sem{e1 ⊕ e2} =1 \sem{e1} ∪ \sem{e2}.
93 #S * #i1 #b1 * #i2 #b2 #w %
94 [cases b1 cases b2 normalize /2/ * /3/ * /3/
95 |cases b1 cases b2 normalize /2/ * /3/ * /3/
101 〈i1,true〉 ▹ i2 = i1 ◃ (•i2).
104 lemma odot_true_bis :
106 〈i1,true〉 ▹ i2 = 〈i1 · \fst (•i2), \snd (•i2)〉.
107 #S #i1 #i2 normalize cases (•i2) // qed.
111 〈i1,false〉 ▹ i2 = 〈i1 · i2, false〉.
114 lemma LcatE : ∀S.∀e1,e2:pitem S.
115 \sem{e1 · e2} = \sem{e1} · \sem{|e2|} ∪ \sem{e2}.
118 lemma erase_bull : ∀S.∀i:pitem S. |\fst (•i)| = |i|.
120 [ #i1 #i2 #IH1 #IH2 >erase_dot <IH1 >eclose_dot
121 cases (•i1) #i11 #b1 cases b1 // <IH2 >odot_true_bis //
122 | #i1 #i2 #IH1 #IH2 >eclose_plus >(erase_plus … i1) <IH1 <IH2
123 cases (•i1) #i11 #b1 cases (•i2) #i21 #b2 //
124 | #i #IH >eclose_star >(erase_star … i) <IH cases (•i) //
129 lemma sem_eclose_star: ∀S:DeqSet.∀i:pitem S.
130 \sem{〈i^*,true〉} =1 \sem{〈i,false〉}·\sem{|i|}^* ∪ {ϵ}.
134 (* theorem 16: 1 → 3 *)
135 lemma odot_dot_aux : ∀S.∀e1:pre S.∀i2:pitem S.
136 \sem{•i2} =1 \sem{i2} ∪ \sem{|i2|} →
137 \sem{e1 ▹ i2} =1 \sem{e1} · \sem{|i2|} ∪ \sem{i2}.
138 #S * #i1 #b1 #i2 cases b1
139 [2:#th >odot_false >sem_pre_false >sem_pre_false >sem_cat /2/
140 |#H >odot_true >sem_pre_true @(eqP_trans … (sem_pre_concat_r …))
141 >erase_bull @eqP_trans [|@(eqP_union_l … H)]
142 @eqP_trans [|@eqP_union_l[|@union_comm ]]
143 @eqP_trans [|@eqP_sym @union_assoc ] /3/
147 lemma minus_eps_pre_aux: ∀S.∀e:pre S.∀i:pitem S.∀A.
148 \sem{e} =1 \sem{i} ∪ A → \sem{\fst e} =1 \sem{i} ∪ (A - {[ ]}).
150 @eqP_trans [|@minus_eps_pre]
151 @eqP_trans [||@eqP_union_r [|@eqP_sym @minus_eps_item]]
152 @eqP_trans [||@distribute_substract]
157 theorem sem_bull: ∀S:DeqSet. ∀i:pitem S. \sem{•i} =1 \sem{i} ∪ \sem{|i|}.
159 [#w normalize % [/2/ | * //]
161 |#x normalize #w % [ /2/ | * [@False_ind | //]]
162 |#x normalize #w % [ /2/ | * // ]
163 |#i1 #i2 #IH1 #IH2 >eclose_dot
164 @eqP_trans [|@odot_dot_aux //] >sem_cat
167 [|@eqP_trans [|@(cat_ext_l … IH1)] @distr_cat_r]]
168 @eqP_trans [|@union_assoc]
169 @eqP_trans [||@eqP_sym @union_assoc]
171 |#i1 #i2 #IH1 #IH2 >eclose_plus
172 @eqP_trans [|@sem_oplus] >sem_plus >erase_plus
173 @eqP_trans [|@(eqP_union_l … IH2)]
174 @eqP_trans [|@eqP_sym @union_assoc]
175 @eqP_trans [||@union_assoc] @eqP_union_r
176 @eqP_trans [||@eqP_sym @union_assoc]
177 @eqP_trans [||@eqP_union_l [|@union_comm]]
178 @eqP_trans [||@union_assoc] /2/
179 |#i #H >sem_pre_true >sem_star >erase_bull >sem_star
180 @eqP_trans [|@eqP_union_r [|@cat_ext_l [|@minus_eps_pre_aux //]]]
181 @eqP_trans [|@eqP_union_r [|@distr_cat_r]]
182 @eqP_trans [|@union_assoc] @eqP_union_l >erase_star
183 @eqP_sym @star_fix_eps
188 let rec blank (S: DeqSet) (i: re S) on i :pitem S ≝
193 | o e1 e2 ⇒ (blank S e1) + (blank S e2)
194 | c e1 e2 ⇒ (blank S e1) · (blank S e2)
195 | k e ⇒ (blank S e)^* ].
197 lemma forget_blank: ∀S.∀e:re S.|blank S e| = e.
198 #S #e elim e normalize //
201 lemma sem_blank: ∀S.∀e:re S.\sem{blank S e} =1 ∅.
205 |#e1 #e2 #Hind1 #Hind2 >sem_cat
206 @eqP_trans [||@(union_empty_r … ∅)]
207 @eqP_trans [|@eqP_union_l[|@Hind2]] @eqP_union_r
208 @eqP_trans [||@(cat_empty_l … ?)] @cat_ext_l @Hind1
209 |#e1 #e2 #Hind1 #Hind2 >sem_plus
210 @eqP_trans [||@(union_empty_r … ∅)]
211 @eqP_trans [|@eqP_union_l[|@Hind2]] @eqP_union_r @Hind1
213 @eqP_trans [||@(cat_empty_l … ?)] @cat_ext_l @Hind
217 theorem re_embedding: ∀S.∀e:re S.
218 \sem{•(blank S e)} =1 \sem{e}.
219 #S #e @eqP_trans [|@sem_bull] >forget_blank
220 @eqP_trans [|@eqP_union_r [|@sem_blank]]
221 @eqP_trans [|@union_comm] @union_empty_r.
224 (* lefted operations *)
225 definition lifted_cat ≝ λS:DeqSet.λe:pre S.
226 lift S (pre_concat_l S eclose e).
228 notation "e1 ⊙ e2" left associative with precedence 70 for @{'odot $e1 $e2}.
230 interpretation "lifted cat" 'odot e1 e2 = (lifted_cat ? e1 e2).
232 lemma odot_true_b : ∀S.∀i1,i2:pitem S.∀b.
233 〈i1,true〉 ⊙ 〈i2,b〉 = 〈i1 · (\fst (•i2)),\snd (•i2) ∨ b〉.
234 #S #i1 #i2 #b normalize in ⊢ (??%?); cases (•i2) //
237 lemma odot_false_b : ∀S.∀i1,i2:pitem S.∀b.
238 〈i1,false〉 ⊙ 〈i2,b〉 = 〈i1 · i2 ,b〉.
242 lemma erase_odot:∀S.∀e1,e2:pre S.
243 |\fst (e1 ⊙ e2)| = |\fst e1| · (|\fst e2|).
244 #S * #i1 * * #i2 #b2 // >odot_true_b >erase_dot //
247 definition lk ≝ λS:DeqSet.λe:pre S.
251 [true ⇒ 〈(\fst (eclose ? i1))^*, true〉
252 |false ⇒ 〈i1^*,false〉
256 (* notation < "a \sup ⊛" non associative with precedence 90 for @{'lk $a}.*)
257 interpretation "lk" 'lk a = (lk ? a).
258 notation "a^⊛" non associative with precedence 90 for @{'lk $a}.
261 lemma ostar_true: ∀S.∀i:pitem S.
262 〈i,true〉^⊛ = 〈(\fst (•i))^*, true〉.
265 lemma ostar_false: ∀S.∀i:pitem S.
266 〈i,false〉^⊛ = 〈i^*, false〉.
269 lemma erase_ostar: ∀S.∀e:pre S.
270 |\fst (e^⊛)| = |\fst e|^*.
273 lemma sem_odot_true: ∀S:DeqSet.∀e1:pre S.∀i.
274 \sem{e1 ⊙ 〈i,true〉} =1 \sem{e1 ▹ i} ∪ { [ ] }.
276 cut (e1 ⊙ 〈i,true〉 = 〈\fst (e1 ▹ i), \snd(e1 ▹ i) ∨ true〉) [//]
277 #H >H cases (e1 ▹ i) #i1 #b1 cases b1
278 [>sem_pre_true @eqP_trans [||@eqP_sym @union_assoc]
284 lemma eq_odot_false: ∀S:DeqSet.∀e1:pre S.∀i.
285 e1 ⊙ 〈i,false〉 = e1 ▹ i.
287 cut (e1 ⊙ 〈i,false〉 = 〈\fst (e1 ▹ i), \snd(e1 ▹ i) ∨ false〉) [//]
288 cases (e1 ▹ i) #i1 #b1 cases b1 #H @H
292 ∀S.∀e1,e2: pre S. \sem{e1 ⊙ e2} =1 \sem{e1}· \sem{|\fst e2|} ∪ \sem{e2}.
295 @eqP_trans [|@sem_odot_true]
296 @eqP_trans [||@union_assoc] @eqP_union_r @odot_dot_aux //
297 |>sem_pre_false >eq_odot_false @odot_dot_aux //
302 theorem sem_ostar: ∀S.∀e:pre S.
303 \sem{e^⊛} =1 \sem{e} · \sem{|\fst e|}^*.
305 [>sem_pre_true >sem_pre_true >sem_star >erase_bull
306 @eqP_trans [|@eqP_union_r[|@cat_ext_l [|@minus_eps_pre_aux //]]]
307 @eqP_trans [|@eqP_union_r [|@distr_cat_r]]
308 @eqP_trans [||@eqP_sym @distr_cat_r]
309 @eqP_trans [|@union_assoc] @eqP_union_l
310 @eqP_trans [||@eqP_sym @epsilon_cat_l] @eqP_sym @star_fix_eps
311 |>sem_pre_false >sem_pre_false >sem_star /2/