]> matita.cs.unibo.it Git - helm.git/blob - weblib/tutorial/chapter8.ma
commit by user andrea
[helm.git] / weblib / tutorial / chapter8.ma
1 (*
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.
8
9 \ 5b\ 6Example\ 5/b\ 6
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〉
17 *)
18
19 include "tutorial/chapter7.ma".
20
21 (* Broadcasting a point inside an item generates a pre, since the point could possibly reach 
22 the end of the expression. 
23 Broadcasting inside a i1+i2 amounts to broadcast in parallel inside i1 and i2.
24 If we define
25                  〈i1,b1〉 ⊕ 〈i2,b2〉 = 〈i1 + i2, b1∨ b2〉
26 then, we just have •(i1+i2) = •(i1)⊕ •(i2).
27 *)
28
29 include "tutorial/chapter7.ma".
30
31 definition lo ≝ λS:\ 5a href="cic:/matita/tutorial/chapter4/DeqSet.ind(1,0,0)"\ 6DeqSet\ 5/a\ 6.λa,b:\ 5a href="cic:/matita/tutorial/chapter7/pre.def(1)"\ 6pre\ 5/a\ 6 S.\ 5a title="Pair construction" href="cic:/fakeuri.def(1)"\ 6\ 5/a\ 6\ 5a title="pair pi1" href="cic:/fakeuri.def(1)"\ 6\fst\ 5/a\ 6 a \ 5a title="pitem or" href="cic:/fakeuri.def(1)"\ 6+\ 5/a\ 6 \ 5a title="pair pi1" href="cic:/fakeuri.def(1)"\ 6\fst\ 5/a\ 6 b,\ 5a title="pair pi2" href="cic:/fakeuri.def(1)"\ 6\snd\ 5/a\ 6 a \ 5a title="boolean or" href="cic:/fakeuri.def(1)"\ 6\ 5/a\ 6 \ 5a title="pair pi2" href="cic:/fakeuri.def(1)"\ 6\snd\ 5/a\ 6 b〉.
32 notation "a ⊕ b" left associative with precedence 60 for @{'oplus $a $b}.
33 interpretation "oplus" 'oplus a b = (lo ? a b).
34
35 lemma lo_def: ∀S.∀i1,i2:\ 5a href="cic:/matita/tutorial/chapter7/pitem.ind(1,0,1)"\ 6pitem\ 5/a\ 6 S.∀b1,b2. \ 5a title="Pair construction" href="cic:/fakeuri.def(1)"\ 6\ 5/a\ 6i1,b1〉\ 5a title="oplus" href="cic:/fakeuri.def(1)"\ 6\ 5/a\ 6\ 5a title="Pair construction" href="cic:/fakeuri.def(1)"\ 6\ 5/a\ 6i2,b2〉\ 5a title="leibnitz's equality" href="cic:/fakeuri.def(1)"\ 6=\ 5/a\ 6\ 5a title="Pair construction" href="cic:/fakeuri.def(1)"\ 6\ 5/a\ 6i1\ 5a title="pitem or" href="cic:/fakeuri.def(1)"\ 6+\ 5/a\ 6i2,b1\ 5a title="boolean or" href="cic:/fakeuri.def(1)"\ 6\ 5/a\ 6b2〉.
36 // qed.
37
38 (*
39 Concatenation is a bit more complex. In order to broadcast a point inside i1 · i2 
40 we should start broadcasting it inside i1 and then proceed into i2 if and only if a 
41 point reached the end of i1. This suggests to define •(i1 · i2) as •(i1) ▹ i2, where 
42 e ▹ i is a general operation of concatenation between a pre and an item, defined by 
43 cases on the boolean in e: 
44
45        〈i1,true〉 ▹ i2  = i1 ◃ •(i_2)
46        〈i1,false〉 ▹ i2 = i1 · i2
47 In turn, ◃ says how to concatenate an item with a pre, that is however extremely simple:
48         i1 ◃ 〈i1,b〉  = 〈i_1 · i2, b〉
49 Let us come to the formalized definitions:
50 *)
51
52 definition pre_concat_r ≝ λS:\ 5a href="cic:/matita/tutorial/chapter4/DeqSet.ind(1,0,0)"\ 6DeqSet\ 5/a\ 6.λi:\ 5a href="cic:/matita/tutorial/chapter7/pitem.ind(1,0,1)"\ 6pitem\ 5/a\ 6 S.λe:\ 5a href="cic:/matita/tutorial/chapter7/pre.def(1)"\ 6pre\ 5/a\ 6 S.
53   match e with [ mk_Prod i1 b ⇒ \ 5a title="Pair construction" href="cic:/fakeuri.def(1)"\ 6\ 5/a\ 6\ 5a title="pitem cat" href="cic:/fakeuri.def(1)"\ 6·\ 5/a\ 6 i1, b〉].
54  
55 notation "i ◃ e" left associative with precedence 60 for @{'lhd $i $e}.
56 interpretation "pre_concat_r" 'lhd i e = (pre_concat_r ? i e).
57
58 lemma eq_to_ex_eq: ∀S.∀A,B:\ 5a href="cic:/matita/tutorial/chapter6/word.def(3)"\ 6word\ 5/a\ 6 S → Prop. 
59   A \ 5a title="leibnitz's equality" href="cic:/fakeuri.def(1)"\ 6=\ 5/a\ 6 B → A \ 5a title="extensional equality" href="cic:/fakeuri.def(1)"\ 6=\ 5/a\ 61 B. 
60 #S #A #B #H >H #x % // qed.
61
62 (* The behaviour of ◃ is summarized by the following, easy lemma: *)
63
64 lemma sem_pre_concat_r : ∀S,i.∀e:\ 5a href="cic:/matita/tutorial/chapter7/pre.def(1)"\ 6pre\ 5/a\ 6 S.
65   \ 5a title="in_prl" href="cic:/fakeuri.def(1)"\ 6\sem\ 5/a\ 6{i \ 5a title="pre_concat_r" href="cic:/fakeuri.def(1)"\ 6\ 5/a\ 6 e} \ 5a title="extensional equality" href="cic:/fakeuri.def(1)"\ 6=\ 5/a\ 6\ 5a title="in_pl" href="cic:/fakeuri.def(1)"\ 6\sem\ 5/a\ 6{i} \ 5a title="cat lang" href="cic:/fakeuri.def(1)"\ 6·\ 5/a\ 6 \ 5a title="in_l" href="cic:/fakeuri.def(1)"\ 6\sem\ 5/a\ 6{\ 5a title="forget" href="cic:/fakeuri.def(1)"\ 6|\ 5/a\ 6\ 5a title="pair pi1" href="cic:/fakeuri.def(1)"\ 6\fst\ 5/a\ 6 e|} \ 5a title="union" href="cic:/fakeuri.def(1)"\ 6\ 5/a\ 6 \ 5a title="in_prl" href="cic:/fakeuri.def(1)"\ 6\sem\ 5/a\ 6{e}.
66 #S #i * #i1 #b1 cases b1 [2: @\ 5a href="cic:/matita/tutorial/chapter8/eq_to_ex_eq.def(4)"\ 6eq_to_ex_eq\ 5/a\ 6 //] 
67 >\ 5a href="cic:/matita/tutorial/chapter7/sem_pre_true.def(9)"\ 6sem_pre_true\ 5/a\ 6 >\ 5a href="cic:/matita/tutorial/chapter7/sem_cat.def(8)"\ 6sem_cat\ 5/a\ 6 >\ 5a href="cic:/matita/tutorial/chapter7/sem_pre_true.def(9)"\ 6sem_pre_true\ 5/a\ 6 /\ 5span class="autotactic"\ 62\ 5span class="autotrace"\ 6 trace \ 5/span\ 6\ 5/span\ 6
68 qed.
69  
70 (* The definition of $•(-)$ (eclose) and ▹ (pre_concat_l) are mutually recursive.
71 In this situation, a viable alternative that is usually simpler to reason about, 
72 is to abstract one of the two functions with respect to the other. In particular
73 we abstract pre_concat_l with respect to an input bcast function from items to
74 pres. *)
75
76 definition pre_concat_l ≝ λS:\ 5a href="cic:/matita/tutorial/chapter4/DeqSet.ind(1,0,0)"\ 6DeqSet\ 5/a\ 6.λbcast:∀S:\ 5a href="cic:/matita/tutorial/chapter4/DeqSet.ind(1,0,0)"\ 6DeqSet\ 5/a\ 6.\ 5a href="cic:/matita/tutorial/chapter7/pitem.ind(1,0,1)"\ 6pitem\ 5/a\ 6 S → \ 5a href="cic:/matita/tutorial/chapter7/pre.def(1)"\ 6pre\ 5/a\ 6 S.λe1:\ 5a href="cic:/matita/tutorial/chapter7/pre.def(1)"\ 6pre\ 5/a\ 6 S.λi2:\ 5a href="cic:/matita/tutorial/chapter7/pitem.ind(1,0,1)"\ 6pitem\ 5/a\ 6 S.
77   match e1 with 
78   [ mk_Prod i1 b1 ⇒ match b1 with 
79     [ true ⇒ (i1 \ 5a title="pre_concat_r" href="cic:/fakeuri.def(1)"\ 6\ 5/a\ 6 (bcast ? i2)) 
80     | false ⇒ \ 5a title="Pair construction" href="cic:/fakeuri.def(1)"\ 6\ 5/a\ 6i1 \ 5a title="pitem cat" href="cic:/fakeuri.def(1)"\ 6·\ 5/a\ 6 i2,\ 5a href="cic:/matita/basics/bool/bool.con(0,2,0)"\ 6false\ 5/a\ 6
81     ]
82   ].
83
84 notation "a ▹ b" left associative with precedence 60 for @{'tril eclose $a $b}.
85 interpretation "item-pre concat" 'tril op a b = (pre_concat_l ? op a b).
86
87 (* We are ready to give the formal definition of the broadcasting operation. *)
88
89 notation "•" non associative with precedence 60 for @{eclose ?}.
90
91 let rec eclose (S: \ 5a href="cic:/matita/tutorial/chapter4/DeqSet.ind(1,0,0)"\ 6DeqSet\ 5/a\ 6) (i: \ 5a href="cic:/matita/tutorial/chapter7/pitem.ind(1,0,1)"\ 6pitem\ 5/a\ 6 S) on i : \ 5a href="cic:/matita/tutorial/chapter7/pre.def(1)"\ 6pre\ 5/a\ 6 S ≝
92  match i with
93   [ pz ⇒ \ 5a title="Pair construction" href="cic:/fakeuri.def(1)"\ 6\ 5/a\ 6 \ 5a href="cic:/matita/tutorial/chapter7/pitem.con(0,1,1)"\ 6pz\ 5/a\ 6 ?, \ 5a href="cic:/matita/basics/bool/bool.con(0,2,0)"\ 6false\ 5/a\ 6 〉
94   | pe ⇒ \ 5a title="Pair construction" href="cic:/fakeuri.def(1)"\ 6\ 5/a\ 6 \ 5a title="pitem epsilon" href="cic:/fakeuri.def(1)"\ 6ϵ\ 5/a\ 6,  \ 5a href="cic:/matita/basics/bool/bool.con(0,1,0)"\ 6true\ 5/a\ 6 〉
95   | ps x ⇒ \ 5a title="Pair construction" href="cic:/fakeuri.def(1)"\ 6\ 5/a\ 6 \ 5a title="pitem pp" href="cic:/fakeuri.def(1)"\ 6`\ 5/a\ 6.x, \ 5a href="cic:/matita/basics/bool/bool.con(0,2,0)"\ 6false\ 5/a\ 6
96   | pp x ⇒ \ 5a title="Pair construction" href="cic:/fakeuri.def(1)"\ 6\ 5/a\ 6 \ 5a title="pitem pp" href="cic:/fakeuri.def(1)"\ 6`\ 5/a\ 6.x, \ 5a href="cic:/matita/basics/bool/bool.con(0,2,0)"\ 6false\ 5/a\ 6 〉
97   | po i1 i2 ⇒ •i1 \ 5a title="oplus" href="cic:/fakeuri.def(1)"\ 6\ 5/a\ 6 •i2
98   | pc i1 i2 ⇒ •i1 \ 5a title="item-pre concat" href="cic:/fakeuri.def(1)"\ 6\ 5/a\ 6 i2
99   | pk i ⇒ \ 5a title="Pair construction" href="cic:/fakeuri.def(1)"\ 6\ 5/a\ 6(\ 5a title="pair pi1" href="cic:/fakeuri.def(1)"\ 6\fst\ 5/a\ 6 (•i))\ 5a title="pitem star" href="cic:/fakeuri.def(1)"\ 6^\ 5/a\ 6*,\ 5a href="cic:/matita/basics/bool/bool.con(0,1,0)"\ 6true\ 5/a\ 6〉].
100   
101 notation "• x" non associative with precedence 60 for @{'eclose $x}.
102 interpretation "eclose" 'eclose x = (eclose ? x).
103
104 (* Here are a few simple properties of ▹ and •(-) *)
105
106 lemma pcl_true : 
107   ∀S.∀i1,i2:pitem S.
108   〈i1,true〉 ▸ i2 = i1 ◂ (•i2).
109 // qed.
110
111 lemma pcl_true_bis : 
112   ∀S.∀i1,i2:pitem S.
113   〈i1,true〉 ▸ i2 = 〈i1 · \fst (•i2), \snd (•i2)〉.
114 #S #i1 #i2 normalize cases (•i2) // qed.
115
116 lemma pcl_false: 
117   ∀S.∀i1,i2:pitem S.
118   〈i1,false〉 ▸ i2 = 〈i1 · i2, false〉.
119 // qed.
120
121 lemma eclose_plus: ∀S:DeqSet.∀i1,i2:pitem S.
122   •(i1 + i2) = •i1 ⊕ •i2.
123 // qed.
124
125 lemma eclose_dot: ∀S:DeqSet.∀i1,i2:pitem S.
126   •(i1 · i2) = •i1 ▹ i2.
127 // qed.
128
129 lemma eclose_star: ∀S:DeqSet.∀i:pitem S.
130   •i^* = 〈(\fst(•i))^*,true〉.
131 // qed.
132
133 (* The definition of •(-) (eclose) can then be lifted from items to pres
134 in the obvious way. *)
135
136 definition lift ≝ λS.λf:pitem S →pre S.λe:pre S. 
137   match e with 
138   [ mk_Prod i b ⇒ 〈\fst (f i), \snd (f i) ∨ b〉].
139   
140 definition preclose ≝ λS. lift S (eclose S). 
141 interpretation "preclose" 'eclose x = (preclose ? x).
142
143 (* Obviously, broadcasting does not change the carrier of the item,
144 as it is easily proved by structural induction. *)
145
146 lemma erase_bull : ∀S.∀i:pitem S. |\fst (•i)| = |i|.
147 #S #i elim i // 
148   [ #i1 #i2 #IH1 #IH2 >erase_dot <IH1 >eclose_dot
149     cases (•i1) #i11 #b1 cases b1 // <IH2 >odot_true_bis //
150   | #i1 #i2 #IH1 #IH2 >eclose_plus >(erase_plus … i1) <IH1 <IH2
151     cases (•i1) #i11 #b1 cases (•i2) #i21 #b2 //  
152   | #i #IH >eclose_star >(erase_star … i) <IH cases (•i) //
153   ]
154 qed.
155
156 (* We are now ready to state the main semantic properties of $\oplus, 
157 \triangleleft$ and $\bullet(-)$:
158
159 \begin{lstlisting}[language=grafite]
160 lemma sem_oplus: ∀S:DeqSet.∀e1,e2:pre S. 
161   \sem{e1 ⊕ e2} =1 \sem{e1} ∪ \sem{e2}. 
162 lemma sem_pcl : ∀S.∀e1:pre S.∀i2:pitem S. 
163   \sem{e1 ▹ i2} =1  \sem{e1} · \sem{|i2|} ∪ \sem{i2}.
164 theorem sem_bullet: ∀S:DeqSet. ∀i:pitem S.  
165   \sem{•i} =1 \sem{i} ∪ \sem{|i|}.
166 \end{lstlisting}
167 The proof of \verb+sem_oplus+ is straightforward. *)
168
169 lemma sem_oplus: ∀S:DeqSet.∀e1,e2:pre S.
170   \sem{e1 ⊕ e2} =1 \sem{e1} ∪ \sem{e2}. 
171 #S * #i1 #b1 * #i2 #b2 #w %
172   [cases b1 cases b2 normalize /2/ * /3/ * /3/
173   |cases b1 cases b2 normalize /2/ * /3/ * /3/
174   ]
175 qed.
176
177 (* For the others, we proceed as follow: we first prove the following 
178 auxiliary lemma, that assumes sem_bullet:
179
180 lemma sem_pcl_aux: ∀S.∀e1:pre S.∀i2:pitem S.
181    \sem{•i2} =1  \sem{i2} ∪ \sem{|i2|} →
182    \sem{e1 ▹ i2} =1  \sem{e1} · \sem{|i2|} ∪ \sem{i2}.
183
184 Then, using the previous result, we prove sem_bullet by induction 
185 on i. Finally, sem_pcl_aux and sem_bullet give sem_pcl. *)
186
187 lemma LcatE : ∀S.∀e1,e2:pitem S.
188   \sem{e1 · e2} = \sem{e1} · \sem{|e2|} ∪ \sem{e2}. 
189 // qed.
190
191 lemma sem_pcl_aux : ∀S.∀e1:pre S.∀i2:pitem S.
192    \sem{•i2} =1  \sem{i2} ∪ \sem{|i2|} →
193    \sem{e1 ▹ i2} =1  \sem{e1} · \sem{|i2|} ∪ \sem{i2}.
194 #S * #i1 #b1 #i2 cases b1
195   [2:#th >odot_false >sem_pre_false >sem_pre_false >sem_cat /2/
196   |#H >odot_true >sem_pre_true @(eqP_trans … (sem_pre_concat_r …))
197    >erase_bull @eqP_trans [|@(eqP_union_l … H)]
198     @eqP_trans [|@eqP_union_l[|@union_comm ]]
199     @eqP_trans [|@eqP_sym @union_assoc ] /3/ 
200   ]
201 qed.
202   
203 lemma minus_eps_pre_aux: ∀S.∀e:pre S.∀i:pitem S.∀A. 
204  \sem{e} =1 \sem{i} ∪ A → \sem{\fst e} =1 \sem{i} ∪ (A - {[ ]}).
205 #S #e #i #A #seme
206 @eqP_trans [|@minus_eps_pre]
207 @eqP_trans [||@eqP_union_r [|@eqP_sym @minus_eps_item]]
208 @eqP_trans [||@distribute_substract] 
209 @eqP_substract_r //
210 qed.
211
212 (* theorem 16: 1 *)
213 theorem sem_bull: ∀S:DeqSet. ∀i:pitem S.  \sem{•i} =1 \sem{i} ∪ \sem{|i|}.
214 #S #e elim e 
215   [#w normalize % [/2/ | * //]
216   |/2/ 
217   |#x normalize #w % [ /2/ | * [@False_ind | //]]
218   |#x normalize #w % [ /2/ | * // ] 
219   |#i1 #i2 #IH1 #IH2 >eclose_dot
220    @eqP_trans [|@odot_dot_aux //] >sem_cat 
221    @eqP_trans
222      [|@eqP_union_r
223        [|@eqP_trans [|@(cat_ext_l … IH1)] @distr_cat_r]]
224    @eqP_trans [|@union_assoc]
225    @eqP_trans [||@eqP_sym @union_assoc]
226    @eqP_union_l //
227   |#i1 #i2 #IH1 #IH2 >eclose_plus
228    @eqP_trans [|@sem_oplus] >sem_plus >erase_plus 
229    @eqP_trans [|@(eqP_union_l … IH2)]
230    @eqP_trans [|@eqP_sym @union_assoc]
231    @eqP_trans [||@union_assoc] @eqP_union_r
232    @eqP_trans [||@eqP_sym @union_assoc]
233    @eqP_trans [||@eqP_union_l [|@union_comm]]
234    @eqP_trans [||@union_assoc] /2/
235   |#i #H >sem_pre_true >sem_star >erase_bull >sem_star
236    @eqP_trans [|@eqP_union_r [|@cat_ext_l [|@minus_eps_pre_aux //]]]
237    @eqP_trans [|@eqP_union_r [|@distr_cat_r]]
238    @eqP_trans [|@union_assoc] @eqP_union_l >erase_star 
239    @eqP_sym @star_fix_eps 
240   ]
241 qed.
242
243 (* blank item *)
244 let rec blank (S: DeqSet) (i: re S) on i :pitem S ≝
245  match i with
246   [ z ⇒ `∅
247   | e ⇒ ϵ
248   | s y ⇒ `y
249   | o e1 e2 ⇒ (blank S e1) + (blank S e2) 
250   | c e1 e2 ⇒ (blank S e1) · (blank S e2)
251   | k e ⇒ (blank S e)^* ].
252   
253 lemma forget_blank: ∀S.∀e:re S.|blank S e| = e.
254 #S #e elim e normalize //
255 qed.
256
257 lemma sem_blank: ∀S.∀e:re S.\sem{blank S e} =1 ∅.
258 #S #e elim e 
259   [1,2:@eq_to_ex_eq // 
260   |#s @eq_to_ex_eq //
261   |#e1 #e2 #Hind1 #Hind2 >sem_cat 
262    @eqP_trans [||@(union_empty_r … ∅)] 
263    @eqP_trans [|@eqP_union_l[|@Hind2]] @eqP_union_r
264    @eqP_trans [||@(cat_empty_l … ?)] @cat_ext_l @Hind1
265   |#e1 #e2 #Hind1 #Hind2 >sem_plus 
266    @eqP_trans [||@(union_empty_r … ∅)] 
267    @eqP_trans [|@eqP_union_l[|@Hind2]] @eqP_union_r @Hind1
268   |#e #Hind >sem_star
269    @eqP_trans [||@(cat_empty_l … ?)] @cat_ext_l @Hind
270   ]
271 qed.
272    
273 theorem re_embedding: ∀S.∀e:re S. 
274   \sem{•(blank S e)} =1 \sem{e}.
275 #S #e @eqP_trans [|@sem_bull] >forget_blank 
276 @eqP_trans [|@eqP_union_r [|@sem_blank]]
277 @eqP_trans [|@union_comm] @union_empty_r.
278 qed.
279
280 (* lefted operations *)
281 definition lifted_cat ≝ λS:DeqSet.λe:pre S. 
282   lift S (pre_concat_l S eclose e).
283
284 notation "e1 ⊙ e2" left associative with precedence 70 for @{'odot $e1 $e2}.
285
286 interpretation "lifted cat" 'odot e1 e2 = (lifted_cat ? e1 e2).
287
288 lemma odot_true_b : ∀S.∀i1,i2:pitem S.∀b. 
289   〈i1,true〉 ⊙ 〈i2,b〉 = 〈i1 · (\fst (•i2)),\snd (•i2) ∨ b〉.
290 #S #i1 #i2 #b normalize in ⊢ (??%?); cases (•i2) // 
291 qed.
292
293 lemma odot_false_b : ∀S.∀i1,i2:pitem S.∀b.
294   〈i1,false〉 ⊙ 〈i2,b〉 = 〈i1 · i2 ,b〉.
295 // 
296 qed.
297   
298 lemma erase_odot:∀S.∀e1,e2:pre S.
299   |\fst (e1 ⊙ e2)| = |\fst e1| · (|\fst e2|).
300 #S * #i1 * * #i2 #b2 // >odot_true_b >erase_dot //  
301 qed.
302
303 definition lk ≝ λS:DeqSet.λe:pre S.
304   match e with 
305   [ mk_Prod i1 b1 ⇒
306     match b1 with 
307     [true ⇒ 〈(\fst (eclose ? i1))^*, true〉
308     |false ⇒ 〈i1^*,false〉
309     ]
310   ]. 
311
312 (* notation < "a \sup ⊛" non associative with precedence 90 for @{'lk $a}.*)
313 interpretation "lk" 'lk a = (lk ? a).
314 notation "a^⊛" non associative with precedence 90 for @{'lk $a}.
315
316
317 lemma ostar_true: ∀S.∀i:pitem S.
318   〈i,true〉^⊛ = 〈(\fst (•i))^*, true〉.
319 // qed.
320
321 lemma ostar_false: ∀S.∀i:pitem S.
322   〈i,false〉^⊛ = 〈i^*, false〉.
323 // qed.
324   
325 lemma erase_ostar: ∀S.∀e:pre S.
326   |\fst (e^⊛)| = |\fst e|^*.
327 #S * #i * // qed.
328
329 lemma sem_odot_true: ∀S:DeqSet.∀e1:pre S.∀i. 
330   \sem{e1 ⊙ 〈i,true〉} =1 \sem{e1 ▹ i} ∪ { [ ] }.
331 #S #e1 #i 
332 cut (e1 ⊙ 〈i,true〉 = 〈\fst (e1 ▹ i), \snd(e1 ▹ i) ∨ true〉) [//]
333 #H >H cases (e1 ▹ i) #i1 #b1 cases b1 
334   [>sem_pre_true @eqP_trans [||@eqP_sym @union_assoc]
335    @eqP_union_l /2/ 
336   |/2/
337   ]
338 qed.
339
340 lemma eq_odot_false: ∀S:DeqSet.∀e1:pre S.∀i. 
341   e1 ⊙ 〈i,false〉 = e1 ▹ i.
342 #S #e1 #i  
343 cut (e1 ⊙ 〈i,false〉 = 〈\fst (e1 ▹ i), \snd(e1 ▹ i) ∨ false〉) [//]
344 cases (e1 ▹ i) #i1 #b1 cases b1 #H @H
345 qed.
346
347 lemma sem_odot: 
348   ∀S.∀e1,e2: pre S. \sem{e1 ⊙ e2} =1 \sem{e1}· \sem{|\fst e2|} ∪ \sem{e2}.
349 #S #e1 * #i2 * 
350   [>sem_pre_true 
351    @eqP_trans [|@sem_odot_true]
352    @eqP_trans [||@union_assoc] @eqP_union_r @odot_dot_aux //
353   |>sem_pre_false >eq_odot_false @odot_dot_aux //
354   ]
355 qed.
356
357 (* theorem 16: 4 *)      
358 theorem sem_ostar: ∀S.∀e:pre S. 
359   \sem{e^⊛} =1  \sem{e} · \sem{|\fst e|}^*.
360 #S * #i #b cases b
361   [>sem_pre_true >sem_pre_true >sem_star >erase_bull
362    @eqP_trans [|@eqP_union_r[|@cat_ext_l [|@minus_eps_pre_aux //]]]
363    @eqP_trans [|@eqP_union_r [|@distr_cat_r]]
364    @eqP_trans [||@eqP_sym @distr_cat_r]
365    @eqP_trans [|@union_assoc] @eqP_union_l
366    @eqP_trans [||@eqP_sym @epsilon_cat_l] @eqP_sym @star_fix_eps 
367   |>sem_pre_false >sem_pre_false >sem_star /2/
368   ]
369 qed.