3 (**************************************************************************)
6 (* ||A|| A project by Andrea Asperti *)
8 (* ||I|| Developers: *)
9 (* ||T|| The HELM team. *)
10 (* ||A|| http://helm.cs.unibo.it *)
12 (* \ / This file is distributed under the terms of the *)
13 (* v GNU General Public License Version 2 *)
15 (**************************************************************************)
17 include "arithmetics/nat.ma".
18 include "basics/lists/list.ma".
19 include "basics/sets.ma".
21 definition word ≝ λS:DeqSet.list S.
23 inductive re (S: DeqSet) : Type[0] ≝
27 | c: re S → re S → re S
28 | o: re S → re S → re S
31 (* notation < "a \sup ⋇" non associative with precedence 90 for @{ 'pk $a}.*)
32 notation "a ^ *" non associative with precedence 90 for @{ 'pk $a}.
33 interpretation "star" 'pk a = (k ? a).
34 interpretation "or" 'plus a b = (o ? a b).
36 notation "a · b" non associative with precedence 60 for @{ 'pc $a $b}.
37 interpretation "cat" 'pc a b = (c ? a b).
39 (* to get rid of \middot
40 ncoercion c : ∀S:DeqSet.∀p:re S. re S → re S ≝ c on _p : re ? to ∀_:?.?.
43 notation < "a" non associative with precedence 90 for @{ 'ps $a}.
44 notation > "` term 90 a" non associative with precedence 90 for @{ 'ps $a}.
45 interpretation "atom" 'ps a = (s ? a).
47 notation "ϵ" non associative with precedence 90 for @{ 'epsilon }.
48 interpretation "epsilon" 'epsilon = (e ?).
50 notation "`∅" non associative with precedence 90 for @{ 'empty }.
51 interpretation "empty" 'empty = (z ?).
53 let rec flatten (S : DeqSet) (l : list (word S)) on l : word S ≝
54 match l with [ nil ⇒ [ ] | cons w tl ⇒ w @ flatten ? tl ].
56 let rec conjunct (S : DeqSet) (l : list (word S)) (r : word S → Prop) on l: Prop ≝
57 match l with [ nil ⇒ True | cons w tl ⇒ r w ∧ conjunct ? tl r ].
60 definition empty_lang ≝ λS.λw:word S.False.
61 notation "{}" non associative with precedence 90 for @{'empty_lang}.
62 interpretation "empty lang" 'empty_lang = (empty_lang ?).
64 definition sing_lang ≝ λS.λx,w:word S.x=w.
65 (* notation "{x}" non associative with precedence 90 for @{'sing_lang $x}.*)
66 interpretation "sing lang" 'singl x = (sing_lang ? x).
68 definition union : ∀S,l1,l2,w.Prop ≝ λS.λl1,l2.λw:word S.l1 w ∨ l2 w.
69 interpretation "union lang" 'union a b = (union ? a b). *)
71 definition cat : ∀S,l1,l2,w.Prop ≝
72 λS.λl1,l2.λw:word S.∃w1,w2.w1 @ w2 = w ∧ l1 w1 ∧ l2 w2.
73 interpretation "cat lang" 'pc a b = (cat ? a b).
75 definition star ≝ λS.λl.λw:word S.∃lw.flatten ? lw = w ∧ conjunct ? lw l.
76 interpretation "star lang" 'pk l = (star ? l).
78 let rec in_l (S : DeqSet) (r : re S) on r : word S → Prop ≝
83 | c r1 r2 ⇒ (in_l ? r1) · (in_l ? r2)
84 | o r1 r2 ⇒ (in_l ? r1) ∪ (in_l ? r2)
85 | k r1 ⇒ (in_l ? r1) ^*].
87 notation "\sem{term 19 E}" non associative with precedence 75 for @{'in_l $E}.
88 interpretation "in_l" 'in_l E = (in_l ? E).
89 interpretation "in_l mem" 'mem w l = (in_l ? l w).
91 lemma rsem_star : ∀S.∀r: re S. \sem{r^*} = \sem{r}^*.
94 inductive pitem (S: DeqSet) : Type[0] ≝
99 | pc: pitem S → pitem S → pitem S
100 | po: pitem S → pitem S → pitem S
101 | pk: pitem S → pitem S.
103 definition pre ≝ λS.pitem S × bool.
105 interpretation "pstar" 'pk a = (pk ? a).
106 interpretation "por" 'plus a b = (po ? a b).
107 interpretation "pcat" 'pc a b = (pc ? a b).
108 notation < ".a" non associative with precedence 90 for @{ 'pp $a}.
109 notation > "`. term 90 a" non associative with precedence 90 for @{ 'pp $a}.
110 interpretation "ppatom" 'pp a = (pp ? a).
112 (* to get rid of \middot
113 ncoercion pc : ∀S.∀p:pitem S. pitem S → pitem S ≝ pc on _p : pitem ? to ∀_:?.?.
116 interpretation "patom" 'ps a = (ps ? a).
117 interpretation "pepsilon" 'epsilon = (pe ?).
118 interpretation "pempty" 'empty = (pz ?).
120 let rec forget (S: DeqSet) (l : pitem S) on l: re S ≝
126 | pc E1 E2 ⇒ (forget ? E1) · (forget ? E2)
127 | po E1 E2 ⇒ (forget ? E1) + (forget ? E2)
128 | pk E ⇒ (forget ? E)^* ].
130 (* notation < "|term 19 e|" non associative with precedence 70 for @{'forget $e}.*)
131 interpretation "forget" 'norm a = (forget ? a).
133 let rec in_pl (S : DeqSet) (r : pitem S) on r : word S → Prop ≝
139 | pc r1 r2 ⇒ (in_pl ? r1) · \sem{forget ? r2} ∪ (in_pl ? r2)
140 | po r1 r2 ⇒ (in_pl ? r1) ∪ (in_pl ? r2)
141 | pk r1 ⇒ (in_pl ? r1) · \sem{forget ? r1}^* ].
143 interpretation "in_pl" 'in_l E = (in_pl ? E).
144 interpretation "in_pl mem" 'mem w l = (in_pl ? l w).
147 definition epsilon : ∀S:DeqSet.bool → word S → Prop
148 ≝ λS,b.if b then { ([ ] : word S) } else ∅.
150 interpretation "epsilon" 'epsilon = (epsilon ?).
151 notation < "ϵ b" non associative with precedence 90 for @{'app_epsilon $b}.
152 interpretation "epsilon lang" 'app_epsilon b = (epsilon ? b). *)
154 definition in_prl ≝ λS : DeqSet.λp:pre S.
155 if (\snd p) then \sem{\fst p} ∪ { ([ ] : word S) } else \sem{\fst p}.
157 interpretation "in_prl mem" 'mem w l = (in_prl ? l w).
158 interpretation "in_prl" 'in_l E = (in_prl ? E).
160 lemma sem_pre_true : ∀S.∀i:pitem S.
161 \sem{〈i,true〉} = \sem{i} ∪ { ([ ] : word S) }.
164 lemma sem_pre_false : ∀S.∀i:pitem S.
165 \sem{〈i,false〉} = \sem{i}.
168 lemma sem_cat: ∀S.∀i1,i2:pitem S.
169 \sem{i1 · i2} = \sem{i1} · \sem{|i2|} ∪ \sem{i2}.
172 lemma sem_cat_w: ∀S.∀i1,i2:pitem S.∀w.
173 \sem{i1 · i2} w = ((\sem{i1} · \sem{|i2|}) w ∨ \sem{i2} w).
176 lemma sem_plus: ∀S.∀i1,i2:pitem S.
177 \sem{i1 + i2} = \sem{i1} ∪ \sem{i2}.
180 lemma sem_plus_w: ∀S.∀i1,i2:pitem S.∀w.
181 \sem{i1 + i2} w = (\sem{i1} w ∨ \sem{i2} w).
184 lemma sem_star : ∀S.∀i:pitem S.
185 \sem{i^*} = \sem{i} · \sem{|i|}^*.
188 lemma sem_star_w : ∀S.∀i:pitem S.∀w.
189 \sem{i^*} w = (∃w1,w2.w1 @ w2 = w ∧ \sem{i} w1 ∧ \sem{|i|}^* w2).
192 lemma append_eq_nil : ∀S.∀w1,w2:word S. w1 @ w2 = [ ] → w1 = [ ].
193 #S #w1 #w2 cases w1 // #a #tl normalize #H destruct qed.
195 lemma not_epsilon_lp : ∀S:DeqSet.∀e:pitem S. ¬ ([ ] ∈ e).
196 #S #e elim e normalize /2/
197 [#r1 #r2 * #n1 #n2 % * /2/ * #w1 * #w2 * * #H
198 >(append_eq_nil …H…) /2/
199 |#r1 #r2 #n1 #n2 % * /2/
200 |#r #n % * #w1 * #w2 * * #H >(append_eq_nil …H…) /2/
205 lemma epsilon_to_true : ∀S.∀e:pre S. [ ] ∈ e → \snd e = true.
206 #S * #i #b cases b // normalize #H @False_ind /2/
209 lemma true_to_epsilon : ∀S.∀e:pre S. \snd e = true → [ ] ∈ e.
210 #S * #i #b #btrue normalize in btrue; >btrue %2 //
213 definition lo ≝ λS:DeqSet.λa,b:pre S.〈\fst a + \fst b,\snd a ∨ \snd b〉.
214 notation "a ⊕ b" left associative with precedence 60 for @{'oplus $a $b}.
215 interpretation "oplus" 'oplus a b = (lo ? a b).
217 lemma lo_def: ∀S.∀i1,i2:pitem S.∀b1,b2. 〈i1,b1〉⊕〈i2,b2〉=〈i1+i2,b1∨b2〉.
220 definition pre_concat_r ≝ λS:DeqSet.λi:pitem S.λe:pre S.
221 match e with [ mk_Prod i1 b ⇒ 〈i · i1, b〉].
223 notation "i ◂ e" left associative with precedence 60 for @{'ltrif $i $e}.
224 interpretation "pre_concat_r" 'ltrif i e = (pre_concat_r ? i e).
226 definition eq_f1 ≝ λS.λa,b:word S → Prop.∀w.a w ↔ b w.
227 notation "A =1 B" non associative with precedence 45 for @{'eq_f1 $A $B}.
228 interpretation "eq f1" 'eq_f1 a b = (eq_f1 ? a b).
230 lemma eq_to_ex_eq: ∀S.∀A,B:word S → Prop.
232 #S #A #B #H >H /2/ qed.
234 lemma sem_pre_concat_r : ∀S,i.∀e:pre S.
235 \sem{i ◂ e} =1 \sem{i} · \sem{|\fst e|} ∪ \sem{e}.
236 #S #i * #i1 #b1 cases b1 /2/
237 >sem_pre_true >sem_cat >sem_pre_true /2/
240 definition lc ≝ λS:DeqSet.λbcast:∀S:DeqSet.pitem S → pre S.λe1:pre S.λi2:pitem S.
242 [ mk_Prod i1 b1 ⇒ match b1 with
243 [ true ⇒ (i1 ◂ (bcast ? i2))
244 | false ⇒ 〈i1 · i2,false〉
248 definition lift ≝ λS.λf:pitem S →pre S.λe:pre S.
250 [ mk_Prod i b ⇒ 〈\fst (f i), \snd (f i) ∨ b〉].
252 notation "a ▸ b" left associative with precedence 60 for @{'lc eclose $a $b}.
253 interpretation "lc" 'lc op a b = (lc ? op a b).
255 definition lk ≝ λS:DeqSet.λbcast:∀S:DeqSet.∀E:pitem S.pre S.λe:pre S.
259 [true ⇒ 〈(\fst (bcast ? i1))^*, true〉
260 |false ⇒ 〈i1^*,false〉
265 lemma oplus_tt : ∀S: DeqSet.∀i1,i2:pitem S.
266 〈i1,true〉 ⊕ 〈i2,true〉 = 〈i1 + i2,true〉.
269 lemma oplus_tf : ∀S: DeqSet.∀i1,i2:pitem S.
270 〈i1,true〉 ⊕ 〈i2,false〉 = 〈i1 + i2,true〉.
273 lemma oplus_ft : ∀S: DeqSet.∀i1,i2:pitem S.
274 〈i1,false〉 ⊕ 〈i2,true〉 = 〈i1 + i2,true〉.
277 lemma oplus_ff : ∀S: DeqSet.∀i1,i2:pitem S.
278 〈i1,false〉 ⊕ 〈i2,false〉 = 〈i1 + i2,false〉.
281 (* notation < "a \sup ⊛" non associative with precedence 90 for @{'lk $op $a}.*)
282 interpretation "lk" 'lk op a = (lk ? op a).
283 notation "a^⊛" non associative with precedence 90 for @{'lk eclose $a}.
285 notation "•" non associative with precedence 60 for @{eclose ?}.
287 let rec eclose (S: DeqSet) (i: pitem S) on i : pre S ≝
291 | ps x ⇒ 〈 `.x, false〉
292 | pp x ⇒ 〈 `.x, false 〉
293 | po i1 i2 ⇒ •i1 ⊕ •i2
294 | pc i1 i2 ⇒ •i1 ▸ i2
295 | pk i ⇒ 〈(\fst (•i))^*,true〉].
297 notation "• x" non associative with precedence 60 for @{'eclose $x}.
298 interpretation "eclose" 'eclose x = (eclose ? x).
300 lemma eclose_plus: ∀S:DeqSet.∀i1,i2:pitem S.
301 •(i1 + i2) = •i1 ⊕ •i2.
304 lemma eclose_dot: ∀S:DeqSet.∀i1,i2:pitem S.
305 •(i1 · i2) = •i1 ▸ i2.
308 lemma eclose_star: ∀S:DeqSet.∀i:pitem S.
309 •i^* = 〈(\fst(•i))^*,true〉.
312 definition reclose ≝ λS. lift S (eclose S).
313 interpretation "reclose" 'eclose x = (reclose ? x).
316 lemma sem_oplus: ∀S:DeqSet.∀e1,e2:pre S.
317 \sem{e1 ⊕ e2} =1 \sem{e1} ∪ \sem{e2}.
318 #S * #i1 #b1 * #i2 #b2 #w %
319 [cases b1 cases b2 normalize /2/ * /3/ * /3/
320 |cases b1 cases b2 normalize /2/ * /3/ * /3/
326 〈i1,true〉 ▸ i2 = i1 ◂ (•i2).
329 lemma odot_true_bis :
331 〈i1,true〉 ▸ i2 = 〈i1 · \fst (•i2), \snd (•i2)〉.
332 #S #i1 #i2 normalize cases (•i2) // qed.
336 〈i1,false〉 ▸ i2 = 〈i1 · i2, false〉.
339 lemma LcatE : ∀S.∀e1,e2:pitem S.
340 \sem{e1 · e2} = \sem{e1} · \sem{|e2|} ∪ \sem{e2}.
343 lemma erase_dot : ∀S.∀e1,e2:pitem S. |e1 · e2| = c ? (|e1|) (|e2|).
346 lemma erase_plus : ∀S.∀i1,i2:pitem S.
347 |i1 + i2| = |i1| + |i2|.
350 lemma erase_star : ∀S.∀i:pitem S.|i^*| = |i|^*.
353 lemma erase_bull : ∀S.∀i:pitem S. |\fst (•i)| = |i|.
355 [ #i1 #i2 #IH1 #IH2 >erase_dot <IH1 >eclose_dot
356 cases (•i1) #i11 #b1 cases b1 // <IH2 >odot_true_bis //
357 | #i1 #i2 #IH1 #IH2 >eclose_plus >(erase_plus … i1) <IH1 <IH2
358 cases (•i1) #i11 #b1 cases (•i2) #i21 #b2 //
359 | #i #IH >eclose_star >(erase_star … i) <IH cases (•i) //
363 lemma cat_ext_l: ∀S.∀A,B,C:word S →Prop.
364 A =1 C → A · B =1 C · B.
365 #S #A #B #C #H #w % * #w1 * #w2 * * #eqw #inw1 #inw2
369 lemma cat_ext_r: ∀S.∀A,B,C:word S →Prop.
370 B =1 C → A · B =1 A · C.
371 #S #A #B #C #H #w % * #w1 * #w2 * * #eqw #inw1 #inw2
375 lemma distr_cat_r: ∀S.∀A,B,C:word S →Prop.
376 (A ∪ B) · C =1 A · C ∪ B · C.
378 [* #w1 * #w2 * * #eqw * /6/ |* * #w1 * #w2 * * /6/]
381 lemma espilon_in_star: ∀S.∀A:word S → Prop.
383 #S #A @(ex_intro … [ ]) normalize /2/
386 lemma cat_to_star:∀S.∀A:word S → Prop.
387 ∀w1,w2. A w1 → A^* w2 → A^* (w1@w2).
388 #S #A #w1 #w2 #Aw * #l * #H #H1 @(ex_intro … (w1::l))
392 lemma fix_star: ∀S.∀A:word S → Prop.
393 A^* =1 A · A^* ∪ { [ ] }.
395 [* #l generalize in match w; -w cases l [normalize #w * /2/]
396 #w1 #tl #w * whd in ⊢ ((??%?)→?); #eqw whd in ⊢ (%→?); *
397 #w1A #cw1 %1 @(ex_intro … w1) @(ex_intro … (flatten S tl))
398 % /2/ whd @(ex_intro … tl) /2/
399 |* [2: whd in ⊢ (%→?); #eqw <eqw //]
400 * #w1 * #w2 * * #eqw <eqw @cat_to_star
404 lemma star_fix_eps : ∀S.∀A:word S → Prop.
405 A^* =1 (A - {[ ]}) · A^* ∪ {[ ]}.
408 [* whd in ⊢ ((??%?)→?); #eqw #_ %2 <eqw //
409 |* [#tl #Hind * #H * #_ #H2 @Hind % [@H | //]
410 |#a #w1 #tl #Hind * whd in ⊢ ((??%?)→?); #H1 * #H2 #H3 %1
411 @(ex_intro … (a::w1)) @(ex_intro … (flatten S tl)) %
412 [% [@H1 | normalize % /2/] |whd @(ex_intro … tl) /2/]
415 |* [* #w1 * #w2 * * #eqw * #H1 #_ <eqw @cat_to_star //
416 | whd in ⊢ (%→?); #H <H //
421 lemma star_epsilon: ∀S:DeqSet.∀A:word S → Prop.
422 A^* ∪ { [ ] } =1 A^*.
426 lemma sem_eclose_star: ∀S:DeqSet.∀i:pitem S.
427 \sem{〈i^*,true〉} =1 \sem{〈i,false〉}·\sem{|i|}^* ∪ { [ ] }.
430 (* this kind of results are pretty bad for automation;
431 better not index them *)
433 lemma epsilon_cat_r: ∀S.∀A:word S →Prop.
436 [* #w1 * #w2 * * #eqw #inw1 normalize #eqw2 <eqw //
437 |#inA @(ex_intro … w) @(ex_intro … [ ]) /3/
441 lemma epsilon_cat_l: ∀S.∀A:word S →Prop.
444 [* #w1 * #w2 * * #eqw normalize #eqw2 <eqw <eqw2 //
445 |#inA @(ex_intro … [ ]) @(ex_intro … w) /3/
449 lemma distr_cat_r_eps: ∀S.∀A,C:word S →Prop.
450 (A ∪ { [ ] }) · C =1 A · C ∪ C.
451 #S #A #C @eqP_trans [|@distr_cat_r |@eqP_union_l @epsilon_cat_l]
454 (* axiom eplison_cut_l: ∀S.∀A:word S →Prop.
457 axiom eplison_cut_r: ∀S.∀A:word S →Prop.
461 lemma eta_lp : ∀S.∀p:pre S.𝐋\p p = 𝐋\p 〈\fst p, \snd p〉.
462 #S p; ncases p; //; nqed.
464 nlemma epsilon_dot: ∀S.∀p:word S → Prop. {[]} · p = p.
465 #S e; napply extP; #w; nnormalize; @; ##[##2: #Hw; @[]; @w; /3/; ##]
466 *; #w1; *; #w2; *; *; #defw defw1 Hw2; nrewrite < defw; nrewrite < defw1;
469 (* theorem 16: 1 → 3 *)
470 lemma odot_dot_aux : ∀S.∀e1:pre S.∀i2:pitem S.
471 \sem{•i2} =1 \sem{i2} ∪ \sem{|i2|} →
472 \sem{e1 ▸ i2} =1 \sem{e1} · \sem{|i2|} ∪ \sem{i2}.
473 #S * #i1 #b1 #i2 cases b1
474 [2:#th >odot_false >sem_pre_false >sem_pre_false >sem_cat /2/
475 |#H >odot_true >sem_pre_true @(eqP_trans … (sem_pre_concat_r …))
476 >erase_bull @eqP_trans [|@(eqP_union_l … H)]
477 @eqP_trans [|@eqP_union_l[|@union_comm ]]
478 @eqP_trans [|@eqP_sym @union_assoc ] /3/
482 lemma sem_fst: ∀S.∀e:pre S. \sem{\fst e} =1 \sem{e}-{[ ]}.
484 [>sem_pre_true normalize in ⊢ (??%?); #w %
485 [/3/ | * * // #H1 #H2 @False_ind @(absurd …H1 H2)]
486 |>sem_pre_false normalize in ⊢ (??%?); #w % [ /3/ | * // ]
490 lemma item_eps: ∀S.∀i:pitem S. \sem{i} =1 \sem{i}-{[ ]}.
492 [#H whd % // normalize @(not_to_not … (not_epsilon_lp …i)) //
497 lemma sem_fst_aux: ∀S.∀e:pre S.∀i:pitem S.∀A.
498 \sem{e} =1 \sem{i} ∪ A → \sem{\fst e} =1 \sem{i} ∪ (A - {[ ]}).
500 @eqP_trans [|@sem_fst]
501 @eqP_trans [||@eqP_union_r [|@eqP_sym @item_eps]]
502 @eqP_trans [||@distribute_substract]
507 theorem sem_bull: ∀S:DeqSet. ∀e:pitem S. \sem{•e} =1 \sem{e} ∪ \sem{|e|}.
509 [#w normalize % [/2/ | * //]
511 |#x normalize #w % [ /2/ | * [@False_ind | //]]
512 |#x normalize #w % [ /2/ | * // ]
513 |#i1 #i2 #IH1 #IH2 >eclose_dot
514 @eqP_trans [|@odot_dot_aux //] >sem_cat
517 [|@eqP_trans [|@(cat_ext_l … IH1)] @distr_cat_r]]
518 @eqP_trans [|@union_assoc]
519 @eqP_trans [||@eqP_sym @union_assoc]
521 |#i1 #i2 #IH1 #IH2 >eclose_plus
522 @eqP_trans [|@sem_oplus] >sem_plus >erase_plus
523 @eqP_trans [|@(eqP_union_l … IH2)]
524 @eqP_trans [|@eqP_sym @union_assoc]
525 @eqP_trans [||@union_assoc] @eqP_union_r
526 @eqP_trans [||@eqP_sym @union_assoc]
527 @eqP_trans [||@eqP_union_l [|@union_comm]]
528 @eqP_trans [||@union_assoc] /2/
529 |#i #H >sem_pre_true >sem_star >erase_bull >sem_star
530 @eqP_trans [|@eqP_union_r [|@cat_ext_l [|@sem_fst_aux //]]]
531 @eqP_trans [|@eqP_union_r [|@distr_cat_r]]
532 @eqP_trans [|@union_assoc] @eqP_union_l >erase_star
533 @eqP_sym @star_fix_eps
537 definition lifted_cat ≝ λS:DeqSet.λe:pre S.
538 lift S (lc S eclose e).
540 notation "e1 ⊙ e2" left associative with precedence 70 for @{'odot $e1 $e2}.
542 interpretation "lifted cat" 'odot e1 e2 = (lifted_cat ? e1 e2).
544 lemma odot_true_b : ∀S.∀i1,i2:pitem S.∀b.
545 〈i1,true〉 ⊙ 〈i2,b〉 = 〈i1 · (\fst (•i2)),\snd (•i2) ∨ b〉.
546 #S #i1 #i2 #b normalize in ⊢ (??%?); cases (•i2) //
549 lemma odot_false_b : ∀S.∀i1,i2:pitem S.∀b.
550 〈i1,false〉 ⊙ 〈i2,b〉 = 〈i1 · i2 ,b〉.
554 lemma erase_odot:∀S.∀e1,e2:pre S.
555 |\fst (e1 ⊙ e2)| = |\fst e1| · (|\fst e2|).
556 #S * #i1 * * #i2 #b2 // >odot_true_b //
559 lemma ostar_true: ∀S.∀i:pitem S.
560 〈i,true〉^⊛ = 〈(\fst (•i))^*, true〉.
563 lemma ostar_false: ∀S.∀i:pitem S.
564 〈i,false〉^⊛ = 〈i^*, false〉.
567 lemma erase_ostar: ∀S.∀e:pre S.
568 |\fst (e^⊛)| = |\fst e|^*.
571 lemma sem_odot_true: ∀S:DeqSet.∀e1:pre S.∀i.
572 \sem{e1 ⊙ 〈i,true〉} =1 \sem{e1 ▸ i} ∪ { [ ] }.
574 cut (e1 ⊙ 〈i,true〉 = 〈\fst (e1 ▸ i), \snd(e1 ▸ i) ∨ true〉) [//]
575 #H >H cases (e1 ▸ i) #i1 #b1 cases b1
576 [>sem_pre_true @eqP_trans [||@eqP_sym @union_assoc]
582 lemma eq_odot_false: ∀S:DeqSet.∀e1:pre S.∀i.
583 e1 ⊙ 〈i,false〉 = e1 ▸ i.
585 cut (e1 ⊙ 〈i,false〉 = 〈\fst (e1 ▸ i), \snd(e1 ▸ i) ∨ false〉) [//]
586 cases (e1 ▸ i) #i1 #b1 cases b1 #H @H
590 ∀S.∀e1,e2: pre S. \sem{e1 ⊙ e2} =1 \sem{e1}· \sem{|\fst e2|} ∪ \sem{e2}.
593 @eqP_trans [|@sem_odot_true]
594 @eqP_trans [||@union_assoc] @eqP_union_r @odot_dot_aux //
595 |>sem_pre_false >eq_odot_false @odot_dot_aux //
600 theorem sem_ostar: ∀S.∀e:pre S.
601 \sem{e^⊛} =1 \sem{e} · \sem{|\fst e|}^*.
603 [>sem_pre_true >sem_pre_true >sem_star >erase_bull
604 @eqP_trans [|@eqP_union_r[|@cat_ext_l [|@sem_fst_aux //]]]
605 @eqP_trans [|@eqP_union_r [|@distr_cat_r]]
606 @eqP_trans [||@eqP_sym @distr_cat_r]
607 @eqP_trans [|@union_assoc] @eqP_union_l
608 @eqP_trans [||@eqP_sym @epsilon_cat_l] @eqP_sym @star_fix_eps
609 |>sem_pre_false >sem_pre_false >sem_star /2/
614 nlet rec pre_of_re (S : DeqSet) (e : re S) on e : pitem S ≝
619 | c e1 e2 ⇒ pc ? (pre_of_re ? e1) (pre_of_re ? e2)
620 | o e1 e2 ⇒ po ? (pre_of_re ? e1) (pre_of_re ? e2)
621 | k e1 ⇒ pk ? (pre_of_re ? e1)].
623 nlemma notFalse : ¬False. @; //; nqed.
625 nlemma dot0 : ∀S.∀A:word S → Prop. {} · A = {}.
626 #S A; nnormalize; napply extP; #w; @; ##[##2: *]
627 *; #w1; *; #w2; *; *; //; nqed.
629 nlemma Lp_pre_of_re : ∀S.∀e:re S. 𝐋\p (pre_of_re ? e) = {}.
630 #S e; nelim e; ##[##1,2,3: //]
631 ##[ #e1 e2 H1 H2; nchange in match (𝐋\p (pre_of_re S (e1 e2))) with (?∪?);
632 nrewrite > H1; nrewrite > H2; nrewrite > (dot0…); nrewrite > (cupID…);//
633 ##| #e1 e2 H1 H2; nchange in match (𝐋\p (pre_of_re S (e1+e2))) with (?∪?);
634 nrewrite > H1; nrewrite > H2; nrewrite > (cupID…); //
635 ##| #e1 H1; nchange in match (𝐋\p (pre_of_re S (e1^* ))) with (𝐋\p (pre_of_re ??) · ?);
636 nrewrite > H1; napply dot0; ##]
639 nlemma erase_pre_of_reK : ∀S.∀e. 𝐋 |pre_of_re S e| = 𝐋 e.
641 ##[ #e1 e2 H1 H2; nchange in match (𝐋 (e1 · e2)) with (𝐋 e1·?);
642 nrewrite < H1; nrewrite < H2; //
643 ##| #e1 e2 H1 H2; nchange in match (𝐋 (e1 + e2)) with (𝐋 e1 ∪ ?);
644 nrewrite < H1; nrewrite < H2; //
645 ##| #e1 H1; nchange in match (𝐋 (e1^* )) with ((𝐋 e1)^* );
650 nlemma L_Lp_bull : ∀S.∀e:re S.𝐋 e = 𝐋\p (•pre_of_re ? e).
651 #S e; nrewrite > (bull_cup…); nrewrite > (Lp_pre_of_re…);
652 nrewrite > (cupC…); nrewrite > (cup0…); nrewrite > (erase_pre_of_reK…); //;
655 nlemma Pext : ∀S.∀f,g:word S → Prop. f = g → ∀w.f w → g w.
656 #S f g H; nrewrite > H; //; nqed.
659 ntheorem bull_true_epsilon : ∀S.∀e:pitem S. \snd (•e) = true ↔ [ ] ∈ |e|.
661 ##[ #defsnde; nlapply (bull_cup ? e); nchange in match (𝐋\p (•e)) with (?∪?);
662 nrewrite > defsnde; #H;
663 nlapply (Pext ??? H [ ] ?); ##[ @2; //] *; //;