1 (**************************************************************************)
4 (* ||A|| A project by Andrea Asperti *)
6 (* ||I|| Developers: *)
7 (* ||T|| The HELM team. *)
8 (* ||A|| http://helm.cs.unibo.it *)
10 (* \ / This file is distributed under the terms of the *)
11 (* v GNU General Public License Version 2 *)
13 (**************************************************************************)
15 include "datatypes/pairs-setoids.ma".
16 include "datatypes/bool-setoids.ma".
17 include "datatypes/list-setoids.ma".
18 include "sets/sets.ma".
21 ninductive Admit : CProp[0] ≝ .
25 (* XXX move somewere else *)
26 ndefinition if': ∀A,B:CPROP. A = B → A → B.
29 ncoercion if : ∀A,B:CPROP. ∀p:A = B. A → B ≝ if' on _p : eq_rel1 ???? to ∀_:?.?.
31 (* XXX move to list-setoids-theory.ma *)
33 ntheorem append_nil: ∀A:setoid.∀l:list A.l @ [] = l.
34 #A;#l;nelim l;//; #a;#l1;#IH;nnormalize;/2/;nqed.
36 ndefinition associative ≝ λA:setoid.λf:A → A → A.∀x,y,z.f x (f y z) = f (f x y) z.
38 ntheorem associative_append: ∀A:setoid.associative (list A) (append A).
39 #A;#x;#y;#z;nelim x[ napply (refl ???) |#a;#x1;#H;nnormalize;/2/]nqed.
41 (* end move to list *)
44 (* XXX to undestand what I want inside Alpha
45 the eqb part should be split away, but when available it should be
46 possible to obtain a leibnitz equality on lemmas proved on setoids
48 interpretation "iff" 'iff a b = (iff a b).
50 ninductive eq (A:Type[0]) (x:A) : A → CProp[0] ≝ erefl: eq A x x.
52 nlemma eq_rect_Type0_r':
53 ∀A.∀a,x.∀p:eq ? x a.∀P: ∀x:A. eq ? x a → Type[0]. P a (erefl A a) → P x p.
54 #A; #a; #x; #p; ncases p; #P; #H; nassumption.
57 nlemma eq_rect_Type0_r:
58 ∀A.∀a.∀P: ∀x:A. eq ? x a → Type[0]. P a (erefl A a) → ∀x.∀p:eq ? x a.P x p.
59 #A; #a; #P; #p; #x0; #p0; napply (eq_rect_Type0_r' ??? p0); nassumption.
62 nlemma eq_rect_CProp0_r':
63 ∀A.∀a,x.∀p:eq ? x a.∀P: ∀x:A. eq ? x a → CProp[0]. P a (erefl A a) → P x p.
64 #A; #a; #x; #p; ncases p; #P; #H; nassumption.
67 nlemma eq_rect_CProp0_r:
68 ∀A.∀a.∀P: ∀x:A. eq ? x a → CProp[0]. P a (erefl A a) → ∀x.∀p:eq ? x a.P x p.
69 #A; #a; #P; #p; #x0; #p0; napply (eq_rect_CProp0_r' ??? p0); nassumption.
72 nrecord Alpha : Type[1] ≝ {
74 eqb: acarr → acarr → bool;
75 eqb_true: ∀x,y. (eqb x y = true) = (x = y)
78 interpretation "eqb" 'eq_low a b = (eqb ? a b).
82 ninductive re (S: Type[0]) : Type[0] ≝
86 | c: re S → re S → re S
87 | o: re S → re S → re S
90 notation < "a \sup ⋇" non associative with precedence 90 for @{ 'pk $a}.
91 notation > "a ^ *" non associative with precedence 75 for @{ 'pk $a}.
92 interpretation "star" 'pk a = (k ? a).
93 interpretation "or" 'plus a b = (o ? a b).
95 notation "a · b" non associative with precedence 60 for @{ 'pc $a $b}.
96 interpretation "cat" 'pc a b = (c ? a b).
98 (* to get rid of \middot *)
99 ncoercion c : ∀S.∀p:re S. re S → re S ≝ c on _p : re ? to ∀_:?.?.
101 notation < "a" non associative with precedence 90 for @{ 'ps $a}.
102 notation > "` term 90 a" non associative with precedence 90 for @{ 'ps $a}.
103 interpretation "atom" 'ps a = (s ? a).
105 notation "ϵ" non associative with precedence 90 for @{ 'epsilon }.
106 interpretation "epsilon" 'epsilon = (e ?).
108 notation "0" non associative with precedence 90 for @{ 'empty_r }.
109 interpretation "empty" 'empty_r = (z ?).
111 notation > "'lang' S" non associative with precedence 90 for @{ Ω^(list $S) }.
112 notation > "'Elang' S" non associative with precedence 90 for @{ 𝛀^(list $S) }.
114 (* setoid support for re *)
116 nlet rec eq_re (S:Alpha) (a,b : re S) on a : CProp[0] ≝
118 [ z ⇒ match b with [ z ⇒ True | _ ⇒ False]
119 | e ⇒ match b with [ e ⇒ True | _ ⇒ False]
120 | s x ⇒ match b with [ s y ⇒ x = y | _ ⇒ False]
121 | c r1 r2 ⇒ match b with [ c s1 s2 ⇒ eq_re ? r1 s1 ∧ eq_re ? r2 s2 | _ ⇒ False]
122 | o r1 r2 ⇒ match b with [ o s1 s2 ⇒ eq_re ? r1 s1 ∧ eq_re ? r2 s2 | _ ⇒ False]
123 | k r1 ⇒ match b with [ k r2 ⇒ eq_re ? r1 r2 | _ ⇒ False]].
125 interpretation "eq_re" 'eq_low a b = (eq_re ? a b).
127 ndefinition RE : Alpha → setoid.
128 #A; @(re A); @(eq_re A);
129 ##[ #p; nelim p; /2/;
130 ##| #p1; nelim p1; ##[##1,2: #p2; ncases p2; /2/;
131 ##|##2,3: #x p2; ncases p2; /2/;
132 ##|##4,5: #e1 e2 H1 H2 p2; ncases p2; /3/; #e3 e4; *; #; @; /2/;
133 ##|#r H p2; ncases p2; /2/;##]
135 ##[ ##1,2: #y z; ncases y; ncases z; //; nnormalize; #; ncases (?:False); //;
136 ##| ##3: #a; #y z; ncases y; ncases z; /2/; nnormalize; #; ncases (?:False); //;
137 ##| ##4,5: #r1 r2 H1 H2 y z; ncases y; ncases z; //; nnormalize;
138 ##[##1,3,4,5,6,8: #; ncases (?:False); //;##]
139 #r1 r2 r3 r4; nnormalize; *; #H1 H2; *; #H3 H4; /3/;
140 ##| #r H y z; ncases y; ncases z; //; nnormalize; ##[##1,2,3: #; ncases (?:False); //]
144 unification hint 0 ≔ A : Alpha;
147 P1 ≟ refl ? (eq0 (RE A)),
148 P2 ≟ sym ? (eq0 (RE A)),
149 P3 ≟ trans ? (eq0 (RE A)),
150 X ≟ mk_setoid (re T) (mk_equivalence_relation ? (eq_re A) P1 P2 P3)
151 (*-----------------------------------------------------------------------*) ⊢
154 unification hint 0 ≔ A:Alpha,a,b:re A;
157 (* -------------------------------------------- *) ⊢
158 eq_re A a b ≡ eq_rel L R a b.
160 nlemma c_is_morph : ∀A:Alpha.(re A) ⇒_0 (re A) ⇒_0 (re A).
161 #A; napply (mk_binary_morphism … (λs1,s2:re A. s1 · s2));
163 ##[##1,2: #a' b b'; ncases a'; nnormalize; /2/ by conj;
164 ##|#x a' b b'; ncases a'; /2/ by conj;
165 ##|##4,5: #r1 r2 IH1 IH2 a'; ncases a'; nnormalize; /2/ by conj;
166 ##|#r IH a'; ncases a'; nnormalize; /2/ by conj; ##]
169 (* XXX This is the good format for hints about morphisms, fix the others *)
170 alias symbol "hint_decl" (instance 1) = "hint_decl_Type0".
171 unification hint 0 ≔ S:Alpha, A,B:re S;
172 MM ≟ mk_unary_morphism ??
173 (λA:re S.mk_unary_morphism ?? (λB.A · B) (prop1 ?? (c_is_morph S A)))
174 (prop1 ?? (c_is_morph S)),
176 (*--------------------------------------------------------------------------*) ⊢
177 fun1 T T (fun1 T (unary_morph_setoid T T) MM A) B ≡ A · B.
179 nlemma o_is_morph : ∀A:Alpha.(re A) ⇒_0 (re A) ⇒_0 (re A).
180 #A; napply (mk_binary_morphism … (λs1,s2:re A. s1 + s2));
182 ##[##1,2: #a' b b'; ncases a'; nnormalize; /2/ by conj;
183 ##|#x a' b b'; ncases a'; /2/ by conj;
184 ##|##4,5: #r1 r2 IH1 IH2 a'; ncases a'; nnormalize; /2/ by conj;
185 ##|#r IH a'; ncases a'; nnormalize; /2/ by conj; ##]
188 unification hint 0 ≔ S:Alpha, A,B:re S;
189 MM ≟ mk_unary_morphism ??
190 (λA:re S.mk_unary_morphism ?? (λB.A + B) (prop1 ?? (o_is_morph S A)))
191 (prop1 ?? (o_is_morph S)),
193 (*--------------------------------------------------------------------------*) ⊢
194 fun1 T T (fun1 T (unary_morph_setoid T T) MM A) B ≡ A + B.
196 (* end setoids support for re *)
198 nlet rec conjunct S (l : list (list S)) (L : lang S) on l: CProp[0] ≝
199 match l with [ nil ⇒ True | cons w tl ⇒ w ∈ L ∧ conjunct ? tl L ].
201 interpretation "subset construction with type" 'comprehension t \eta.x =
204 ndefinition cat : ∀A:setoid.∀l1,l2:lang A.lang A ≝
205 λS.λl1,l2.{ w ∈ list S | ∃w1,w2.w =_0 w1 @ w2 ∧ w1 ∈ l1 ∧ w2 ∈ l2}.
206 interpretation "cat lang" 'pc a b = (cat ? a b).
208 ndefinition star : ∀A:setoid.∀l:lang A.lang A ≝
209 λS.λl.{ w ∈ list S | ∃lw.flatten ? lw = w ∧ conjunct ? lw l}.
210 interpretation "star lang" 'pk l = (star ? l).
212 notation > "𝐋 term 70 E" non associative with precedence 75 for @{L_re ? $E}.
213 nlet rec L_re (S : Alpha) (r : re S) on r : lang S ≝
218 | c r1 r2 ⇒ 𝐋 r1 · 𝐋 r2
219 | o r1 r2 ⇒ 𝐋 r1 ∪ 𝐋 r2
221 notation "𝐋 term 70 E" non associative with precedence 75 for @{'L_re $E}.
222 interpretation "in_l" 'L_re E = (L_re ? E).
224 ninductive pitem (S: Type[0]) : Type[0] ≝
229 | pc: pitem S → pitem S → pitem S
230 | po: pitem S → pitem S → pitem S
231 | pk: pitem S → pitem S.
233 interpretation "pstar" 'pk a = (pk ? a).
234 interpretation "por" 'plus a b = (po ? a b).
235 interpretation "pcat" 'pc a b = (pc ? a b).
236 notation < ".a" non associative with precedence 90 for @{ 'pp $a}.
237 notation > "`. term 90 a" non associative with precedence 90 for @{ 'pp $a}.
238 interpretation "ppatom" 'pp a = (pp ? a).
239 (* to get rid of \middot *)
240 ncoercion pc : ∀S.∀p:pitem S. pitem S → pitem S ≝ pc on _p : pitem ? to ∀_:?.?.
241 interpretation "patom" 'ps a = (ps ? a).
242 interpretation "pepsilon" 'epsilon = (pe ?).
243 interpretation "pempty" 'empty_r = (pz ?).
245 (* setoids for pitem *)
246 nlet rec eq_pitem (S : Alpha) (p1, p2 : pitem S) on p1 : CProp[0] ≝
248 [ pz ⇒ match p2 with [ pz ⇒ True | _ ⇒ False]
249 | pe ⇒ match p2 with [ pe ⇒ True | _ ⇒ False]
250 | ps x ⇒ match p2 with [ ps y ⇒ x = y | _ ⇒ False]
251 | pp x ⇒ match p2 with [ pp y ⇒ x = y | _ ⇒ False]
252 | pc a1 a2 ⇒ match p2 with [ pc b1 b2 ⇒ eq_pitem ? a1 b1 ∧ eq_pitem ? a2 b2| _ ⇒ False]
253 | po a1 a2 ⇒ match p2 with [ po b1 b2 ⇒ eq_pitem ? a1 b1 ∧ eq_pitem ? a2 b2| _ ⇒ False]
254 | pk a ⇒ match p2 with [ pk b ⇒ eq_pitem ? a b | _ ⇒ False]].
256 interpretation "eq_pitem" 'eq_low a b = (eq_pitem ? a b).
258 nlemma PITEM : ∀S:Alpha.setoid.
259 #S; @(pitem S); @(eq_pitem …);
260 ##[ #p; nelim p; //; nnormalize; #; @; //;
261 ##| #p; nelim p; ##[##1,2: #y; ncases y; //; ##|##3,4: #x y; ncases y; //; #; napply (?^-1); nassumption;
262 ##|##5,6: #r1 r2 H1 H2 p2; ncases p2; //; #s1 s2; nnormalize; *; #; @; /2/;
263 ##| #r H y; ncases y; //; nnormalize; /2/;##]
265 ##[ ##1,2: #y z; ncases y; ncases z; //; nnormalize; #; ncases (?:False); //;
266 ##| ##3,4: #a; #y z; ncases y; ncases z; /2/; nnormalize; #; ncases (?:False); //;
267 ##| ##5,6: #r1 r2 H1 H2 y z; ncases y; ncases z; //; nnormalize;
268 ##[##1,2,5,6,7,8,4,10: #; ncases (?:False); //;##]
269 #r1 r2 r3 r4; nnormalize; *; #H1 H2; *; #H3 H4; /3/;
270 ##| #r H y z; ncases y; ncases z; //; nnormalize; ##[##1,2,3,4: #; ncases (?:False); //]
274 alias symbol "hint_decl" (instance 1) = "hint_decl_Type1".
275 unification hint 0 ≔ SS:Alpha;
278 P1 ≟ refl ? (eq0 (PITEM SS)),
279 P2 ≟ sym ? (eq0 (PITEM SS)),
280 P3 ≟ trans ? (eq0 (PITEM SS)),
281 R ≟ mk_setoid (pitem S) (mk_equivalence_relation (pitem A) (eq_pitem SS) P1 P2 P3)
282 (*---------------------------*)⊢
285 unification hint 0 ≔ S:Alpha,a,b:pitem S;
288 (* -------------------------------------------- *) ⊢
289 eq_pitem S a b ≡ eq_rel L (eq0 R) a b.
291 (* end setoids for pitem *)
293 ndefinition pre ≝ λS.pitem S × bool.
295 notation "\fst term 90 x" non associative with precedence 90 for @{'fst $x}.
296 interpretation "fst" 'fst x = (fst ? ? x).
297 notation > "\snd term 90 x" non associative with precedence 90 for @{'snd $x}.
298 interpretation "snd" 'snd x = (snd ? ? x).
300 notation > "|term 19 e|" non associative with precedence 70 for @{forget ? $e}.
301 nlet rec forget (S: Alpha) (l : pitem S) on l: re S ≝
307 | pc E1 E2 ⇒ (|E1| · |E2|)
308 | po E1 E2 ⇒ (|E1| + |E2|)
311 notation < "|term 19 e|" non associative with precedence 70 for @{'forget $e}.
312 interpretation "forget" 'forget a = (forget ? a).
314 notation > "𝐋\p\ term 70 E" non associative with precedence 75 for @{L_pi ? $E}.
315 nlet rec L_pi (S : Alpha) (r : pitem S) on r : lang S ≝
321 | pc r1 r2 ⇒ 𝐋\p\ r1 · 𝐋 |r2| ∪ 𝐋\p\ r2
322 | po r1 r2 ⇒ 𝐋\p\ r1 ∪ 𝐋\p\ r2
323 | pk r1 ⇒ 𝐋\p\ r1 · 𝐋 (|r1|^* ) ].
324 notation > "𝐋\p term 70 E" non associative with precedence 75 for @{'L_pi $E}.
325 notation "𝐋\sub(\p) term 70 E" non associative with precedence 75 for @{'L_pi $E}.
326 interpretation "in_pl" 'L_pi E = (L_pi ? E).
328 (* set support for 𝐋\p *)
329 ndefinition L_pi_ext : ∀S:Alpha.∀r:pitem S.Elang S.
330 #S r; @(𝐋\p r); #w1 w2 E; nelim r;
333 ##| #x; @; #H; nchange in H with ([?] =_0 ?); ##[ napply ((.=_0 H) E); ##]
334 napply ((.=_0 H) E^-1);
336 nchange in match (w1 ∈ 𝐋\p (?·?)) with ((∃_.?)∨?);
337 nchange in match (w2 ∈ 𝐋\p (?·?)) with ((∃_.?)∨?); good! *)
339 ncut (∀x1,x2. (w1 = (x1@x2)) = (w2 = (x1@x2)));##[
340 #x1 x2; @; #X; ##[ napply ((.= E^-1) X) | napply ((.= E) X) ] ##] #X;
341 napply ((∑w1,w2. X w1 w2 / H ; (H╪_1#)╪_1#) ╪_1 #);
342 ##| #e1 e2 H1 H2; napply (H1‡H2); (* good! *)
344 ncut (∀x1,x2.(w1 = (x1@x2)) = (w2 = (x1@x2)));##[
345 #x1 x2; @; #X; ##[ napply ((.= E^-1) X) | napply ((.= E) X) ] ##] #X;
346 (* nnormalize in ⊢ (???%%); good! (but a bit too hard) *)
347 napply (∑w1,w2. X w1 w2 / H ; (H╪_1#)╪_1#);
351 unification hint 0 ≔ S : Alpha,e : pitem S;
353 X ≟ (mk_ext_powerclass SS (𝐋\p e) (ext_prop SS (L_pi_ext S e)))
354 (*-----------------------------------------------------------------*)⊢
355 ext_carr SS X ≡ 𝐋\p e.
357 (* end set support for 𝐋\p *)
359 ndefinition epsilon ≝
360 λS:Alpha.λb.match b return λ_.lang S with [ true ⇒ { [ ] } | _ ⇒ ∅ ].
362 interpretation "epsilon" 'epsilon = (epsilon ?).
363 notation < "ϵ b" non associative with precedence 90 for @{'app_epsilon $b}.
364 interpretation "epsilon lang" 'app_epsilon b = (epsilon ? b).
366 ndefinition L_pr ≝ λS : Alpha.λp:pre S. 𝐋\p\ (\fst p) ∪ ϵ (\snd p).
368 interpretation "L_pr" 'L_pi E = (L_pr ? E).
370 nlemma append_eq_nil : ∀S:setoid.∀w1,w2:list S. [ ] = w1 @ w2 → w1 = [ ].
371 #S w1; ncases w1; //. nqed.
373 (* lemma 12 *) (* XXX: a case where Leibnitz equality could be exploited for H *)
374 nlemma epsilon_in_true : ∀S:Alpha.∀e:pre S. [ ] ∈ 𝐋\p e = (\snd e = true).
375 #S r; ncases r; #e b; @; ##[##2: #H; ncases b in H; ##[##2:*] #; @2; /2/; ##]
376 ncases b; //; *; ##[##2:*] nelim e;
377 ##[ ##1,2: *; ##| #c; *; ##| #c; *| ##7: #p H;
378 ##| #r1 r2 H G; *; ##[##2: nassumption; ##]
379 ##| #r1 r2 H1 H2; *; /2/ by {}]
380 *; #w1; *; #w2; *; *;
381 ##[ #defw1 H1 foo; napply H;
382 napply (. (append_eq_nil ? ?? defw1)^-1╪_1#);
384 ##| #defw1 H1 foo; napply H;
385 napply (. (append_eq_nil ? ?? defw1)^-1╪_1#);
390 nlemma not_epsilon_lp : ∀S:Alpha.∀e:pitem S. ¬ ([ ] ∈ (𝐋\p e)).
391 #S e; nelim e; ##[##1,2,3,4: nnormalize;/2/]
392 ##[ #p1 p2 np1 np2; *; ##[##2: napply np2] *; #w1; *; #w2; *; *; #abs;
393 nlapply (append_eq_nil ??? abs); # defw1; #; napply np1;
394 napply (. defw1^-1╪_1#);
396 ##| #p1 p2 np1 np2; *; nchange with (¬?); //;
397 ##| #r n; *; #w1; *; #w2; *; *; #abs; #; napply n;
398 nlapply (append_eq_nil ??? abs); # defw1; #;
399 napply (. defw1^-1╪_1#);
403 ndefinition lo ≝ λS:Alpha.λa,b:pre S.〈\fst a + \fst b,\snd a || \snd b〉.
404 notation "a ⊕ b" left associative with precedence 60 for @{'oplus $a $b}.
405 interpretation "oplus" 'oplus a b = (lo ? a b).
407 ndefinition lc ≝ λS:Alpha.λbcast:∀S:Alpha.∀E:pitem S.pre S.λa,b:pre S.
408 match a with [ mk_pair e1 b1 ⇒
410 [ false ⇒ 〈e1 · \fst b, \snd b〉
411 | true ⇒ 〈e1 · \fst (bcast ? (\fst b)),\snd b || \snd (bcast ? (\fst b))〉]].
413 notation < "a ⊙ b" left associative with precedence 60 for @{'lc $op $a $b}.
414 interpretation "lc" 'lc op a b = (lc ? op a b).
415 notation > "a ⊙ b" left associative with precedence 60 for @{'lc eclose $a $b}.
417 ndefinition lk ≝ λS:Alpha.λbcast:∀S:Alpha.∀E:pitem S.pre S.λa:pre S.
418 match a with [ mk_pair e1 b1 ⇒
420 [ false ⇒ 〈e1^*, false〉
421 | true ⇒ 〈(\fst (bcast ? e1))^*, true〉]].
423 notation < "a \sup ⊛" non associative with precedence 90 for @{'lk $op $a}.
424 interpretation "lk" 'lk op a = (lk ? op a).
425 notation > "a ^ ⊛" non associative with precedence 75 for @{'lk eclose $a}.
427 notation > "•" non associative with precedence 60 for @{eclose ?}.
428 nlet rec eclose (S: Alpha) (E: pitem S) on E : pre S ≝
432 | ps x ⇒ 〈 `.x, false 〉
433 | pp x ⇒ 〈 `.x, false 〉
434 | po E1 E2 ⇒ •E1 ⊕ •E2
435 | pc E1 E2 ⇒ •E1 ⊙ 〈 E2, false 〉
436 | pk E ⇒ 〈(\fst (•E))^*,true〉].
437 notation < "• x" non associative with precedence 60 for @{'eclose $x}.
438 interpretation "eclose" 'eclose x = (eclose ? x).
439 notation > "• x" non associative with precedence 60 for @{'eclose $x}.
441 ndefinition reclose ≝ λS:Alpha.λp:pre S.let p' ≝ •\fst p in 〈\fst p',\snd p || \snd p'〉.
442 interpretation "reclose" 'eclose x = (reclose ? x).
444 nlemma epsilon_or : ∀S:Alpha.∀b1,b2. ϵ(b1 || b2) = ϵ b1 ∪ ϵ b2. ##[##2: napply S]
445 #S b1 b2; ncases b1; ncases b2;
446 nchange in match (true || true) with true;
447 nchange in match (true || false) with true;
448 nchange in match (ϵ true) with {[]};
449 nchange in match (ϵ false) with ∅;
450 ##[##1,4: napply ((cupID…)^-1);
451 ##| napply ((cup0 ? {[]})^-1);
452 ##| napply (.= (cup0 ? {[]})^-1); napply cupC; ##]
456 nlemma oplus_cup : ∀S:Alpha.∀e1,e2:pre S.𝐋\p (e1 ⊕ e2) = 𝐋\p e1 ∪ 𝐋\p e2.
457 #S r1; ncases r1; #e1 b1 r2; ncases r2; #e2 b2; (* oh my!
458 nwhd in ⊢ (???(??%)?);
459 nchange in ⊢(???%?) with (𝐋\p (e1 + e2) ∪ ϵ (b1 || b2));
460 nchange in ⊢(???(??%?)?) with (𝐋\p (e1) ∪ 𝐋\p (e2)); *)
461 napply (.=_1 #╪_1 (epsilon_or ???));
462 napply (.=_1 (cupA…)^-1);
463 napply (.=_1 (cupA…)╪_1#);
464 napply (.=_1 (#╪_1(cupC…))╪_1#);
465 napply (.=_1 (cupA…)^-1╪_1#);
466 napply (.=_1 (cupA…));
471 (* XXX problem: auto does not find # (refl) when it has a concrete == *)
472 nlemma odotEt : ∀S:Alpha.∀e1,e2:pitem S.∀b2:bool.
473 〈e1,true〉 ⊙ 〈e2,b2〉 = 〈e1 · \fst (•e2),b2 || \snd (•e2)〉.
474 #S e1 e2 b2; ncases b2; @; /3/ by refl, conj, I; nqed.
477 nlemma LcatE : ∀S:Alpha.∀e1,e2:pitem S.
478 𝐋\p (e1 · e2) = 𝐋\p e1 · 𝐋 |e2| ∪ 𝐋\p e2. //; nqed.
481 nlemma cup_dotD : ∀S:Alpha.∀p,q,r:lang S.(p ∪ q) · r = (p · r) ∪ (q · r).
482 #S p q r; napply ext_set; #w; nnormalize; @;
483 ##[ *; #x; *; #y; *; *; #defw; *; /7/ by or_introl, or_intror, ex_intro, conj;
484 ##| *; *; #x; *; #y; *; *; /7/ by or_introl, or_intror, ex_intro, conj; ##]
488 nlemma erase_dot : ∀S:Alpha.∀e1,e2:pitem S.𝐋 |e1 · e2| = 𝐋 |e1| · 𝐋 |e2|.
489 #S e1 e2; napply ext_set; nnormalize; #w; @; *; #w1; *; #w2; *; *; /7/ by ex_intro, conj;
492 nlemma erase_plus : ∀S:Alpha.∀e1,e2:pitem S.𝐋 |e1 + e2| = 𝐋 |e1| ∪ 𝐋 |e2|.
493 #S e1 e2; napply ext_set; nnormalize; #w; @; *; /4/ by or_introl, or_intror; nqed.
495 nlemma erase_star : ∀S:Alpha.∀e1:pitem S.𝐋 |e1|^* = 𝐋 |e1^*|. //; nqed.
497 nlemma mem_single : ∀S:setoid.∀a,b:S. a ∈ {(b)} → a = b.
498 #S a b; nnormalize; /2/; nqed.
500 nlemma cup_sub: ∀S.∀A,B:𝛀^S.∀x. ¬ (x ∈ A) → A ∪ (B - {(x)}) = (A ∪ B) - {(x)}.
501 #S A B x H; napply ext_set; #w; @;
502 ##[ *; ##[ #wa; @; ##[@;//] #H2; napply H; napply (. (mem_single ??? H2)^-1╪_1#); //]
503 *; #wb nwn; @; ##[@2;//] //;
504 ##| *; *; ##[ #wa nwn; @; //] #wb nwn; @2; @; //;##]
507 nlemma sub0 : ∀S.∀a:Ω^S. a - ∅ = a.
508 #S a; napply ext_set; #w; nnormalize; @; /3/; *; //; nqed.
510 nlemma subK : ∀S.∀a:Ω^S. a - a = ∅.
511 #S a; napply ext_set; #w; nnormalize; @; *; /2/; nqed.
513 nlemma subW : ∀S.∀a,b:Ω^S.∀w.w ∈ (a - b) → w ∈ a.
514 #S a b w; nnormalize; *; //; nqed.
516 nlemma erase_bull : ∀S:Alpha.∀a:pitem S. |\fst (•a)| = |a|.
517 #S a; nelim a; // by {};
520 napply (.=_0 (IH1^-1)╪_0 (IH2^-1));
521 nchange in match (•(e1 · ?)) with (?⊙?);
522 ncases (•e1); #e3 b; ncases b; ##[ nnormalize; ncases (•e2); /3/ by refl, conj]
523 napply (.=_0 #╪_0 (IH2)); //;
524 ##| #e1 e2 IH1 IH2; napply (?^-1);
525 napply (.=_0 (IH1^-1)╪_0(IH2^-1));
526 nchange in match (•(e1+?)) with (?⊕?);
527 ncases (•e1); ncases (•e2); //]
531 nlemma eta_lp : ∀S:Alpha.∀p:pre S. 𝐋\p p = 𝐋\p 〈\fst p, \snd p〉.
532 #S p; ncases p; //; nqed.
535 (* XXX coercion ext_carr non applica *)
536 nlemma epsilon_dot: ∀S:Alpha.∀p:Elang S. {[]} · (ext_carr ? p) = p.
537 #S e; napply ext_set; #w; @; ##[##2: #Hw; @[]; @w; @; //; @; //; napply #; (* XXX auto *) ##]
538 *; #w1; *; #w2; *; *; #defw defw1 Hw2;
540 napply (. ((defw1 : [ ] = ?)^-1 ╪_0 #)╪_1#);
544 (* theorem 16: 1 → 3 *)
545 nlemma odot_dot_aux : ∀S:Alpha.∀e1,e2: pre S.
546 𝐋\p (•(\fst e2)) = 𝐋\p (\fst e2) ∪ 𝐋 |\fst e2| →
547 𝐋\p (e1 ⊙ e2) = 𝐋\p e1 · 𝐋 |\fst e2| ∪ 𝐋\p e2.
548 #S e1 e2 th1; ncases e1; #e1' b1'; ncases b1';
549 ##[ nchange in match (〈?,true〉⊙?) with 〈?,?〉;
550 nletin e2' ≝ (\fst e2); nletin b2' ≝ (\snd e2);
551 nletin e2'' ≝ (\fst (•(\fst e2))); nletin b2'' ≝ (\snd (•(\fst e2)));
552 napply (.=_1 (# ╪_1 (epsilon_or …))); (* XXX … is too slow if combined with .= *)
553 nchange in match b2'' with b2''; (* XXX some unfoldings happened *)
554 nchange in match b2' with b2';
555 napply (.=_1 (# ╪_1 (cupC …))); napply (.=_1 (cupA …));
556 napply (.=_1 (# ╪_1 (cupA …)^-1)); (* XXX slow, but not because of disamb! *)
557 ncut (𝐋\p e2'' ∪ ϵ b2'' = 𝐋\p e2' ∪ 𝐋 |e2'|); ##[
558 nchange with (𝐋\p 〈e2'',b2''〉 = 𝐋\p e2' ∪ 𝐋 |e2'|);
559 napply (?^-1); napply (.=_1 th1^-1); //;##] #E;
560 napply (.=_1 (# ╪_1 (E ╪_1 #)));
563 nrewrite > (eta_lp ? e2);
564 nchange in match (𝐋\p 〈\fst e2,?〉) with (𝐋\p e2'∪ ϵ b2');
565 nrewrite > (cup_dotD …); nrewrite > (epsilon_dot…);
566 nrewrite > (cupC ? (𝐋\p e2')…); nrewrite > (cupA…);nrewrite > (cupA…);
567 nrewrite < (erase_bull S e2') in ⊢ (???(??%?)); //;
568 ##| ncases e2; #e2' b2'; nchange in match (〈e1',false〉⊙?) with 〈?,?〉;
569 nchange in match (𝐋\p ?) with (?∪?);
570 nchange in match (𝐋\p (e1'·?)) with (?∪?);
571 nchange in match (𝐋\p 〈e1',?〉) with (?∪?);
573 nrewrite > (cupA…); //;##]
576 nlemma sub_dot_star :
577 ∀S.∀X:word S → Prop.∀b. (X - ϵ b) · X^* ∪ {[]} = X^*.
578 #S X b; napply extP; #w; @;
579 ##[ *; ##[##2: nnormalize; #defw; nrewrite < defw; @[]; @; //]
580 *; #w1; *; #w2; *; *; #defw sube; *; #lw; *; #flx cj;
581 @ (w1 :: lw); nrewrite < defw; nrewrite < flx; @; //;
582 @; //; napply (subW … sube);
583 ##| *; #wl; *; #defw Pwl; nrewrite < defw; nelim wl in Pwl; ##[ #_; @2; //]
584 #w' wl' IH; *; #Pw' IHp; nlapply (IH IHp); *;
585 ##[ *; #w1; *; #w2; *; *; #defwl' H1 H2;
586 @; ncases b in H1; #H1;
587 ##[##2: nrewrite > (sub0…); @w'; @(w1@w2);
588 nrewrite > (associative_append ? w' w1 w2);
589 nrewrite > defwl'; @; ##[@;//] @(wl'); @; //;
590 ##| ncases w' in Pw';
591 ##[ #ne; @w1; @w2; nrewrite > defwl'; @; //; @; //;
592 ##| #x xs Px; @(x::xs); @(w1@w2);
593 nrewrite > (defwl'); @; ##[@; //; @; //; @; nnormalize; #; ndestruct]
595 ##| #wlnil; nchange in match (flatten ? (w'::wl')) with (w' @ flatten ? wl');
596 nrewrite < (wlnil); nrewrite > (append_nil…); ncases b;
597 ##[ ncases w' in Pw'; /2/; #x xs Pxs; @; @(x::xs); @([]);
598 nrewrite > (append_nil…); @; ##[ @; //;@; //; nnormalize; @; #; ndestruct]
600 ##| @; @w'; @[]; nrewrite > (append_nil…); @; ##[##2: @[]; @; //]
601 @; //; @; //; @; *;##]##]##]
605 alias symbol "pc" (instance 13) = "cat lang".
606 alias symbol "in_pl" (instance 23) = "in_pl".
607 alias symbol "in_pl" (instance 5) = "in_pl".
608 alias symbol "eclose" (instance 21) = "eclose".
609 ntheorem bull_cup : ∀S:Alpha. ∀e:pitem S. 𝐋\p (•e) = 𝐋\p e ∪ 𝐋 .|e|.
611 ##[ #a; napply extP; #w; nnormalize; @; *; /3/ by or_introl, or_intror;
612 ##| #a; napply extP; #w; nnormalize; @; *; /3/ by or_introl; *;
614 nchange in ⊢ (??(??(%))?) with (•e1 ⊙ 〈e2,false〉);
615 nrewrite > (odot_dot_aux S (•e1) 〈e2,false〉 IH2);
616 nrewrite > (IH1 …); nrewrite > (cup_dotD …);
617 nrewrite > (cupA …); nrewrite > (cupC ?? (𝐋\p ?) …);
618 nchange in match (𝐋\p 〈?,?〉) with (𝐋\p e2 ∪ {}); nrewrite > (cup0 …);
619 nrewrite < (erase_dot …); nrewrite < (cupA …); //;
621 nchange in match (•(?+?)) with (•e1 ⊕ •e2); nrewrite > (oplus_cup …);
622 nrewrite > (IH1 …); nrewrite > (IH2 …); nrewrite > (cupA …);
623 nrewrite > (cupC ? (𝐋\p e2)…);nrewrite < (cupA ??? (𝐋\p e2)…);
624 nrewrite > (cupC ?? (𝐋\p e2)…); nrewrite < (cupA …);
625 nrewrite < (erase_plus …); //.
626 ##| #e; nletin e' ≝ (\fst (•e)); nletin b' ≝ (\snd (•e)); #IH;
627 nchange in match (𝐋\p ?) with (𝐋\p 〈e'^*,true〉);
628 nchange in match (𝐋\p ?) with (𝐋\p (e'^* ) ∪ {[ ]});
629 nchange in ⊢ (??(??%?)?) with (𝐋\p e' · 𝐋 .|e'|^* );
630 nrewrite > (erase_bull…e);
631 nrewrite > (erase_star …);
632 nrewrite > (?: 𝐋\p e' = 𝐋\p e ∪ (𝐋 .|e| - ϵ b')); ##[##2:
633 nchange in IH : (??%?) with (𝐋\p e' ∪ ϵ b'); ncases b' in IH;
634 ##[ #IH; nrewrite > (cup_sub…); //; nrewrite < IH;
635 nrewrite < (cup_sub…); //; nrewrite > (subK…); nrewrite > (cup0…);//;
636 ##| nrewrite > (sub0 …); #IH; nrewrite < IH; nrewrite > (cup0 …);//; ##]##]
637 nrewrite > (cup_dotD…); nrewrite > (cupA…);
638 nrewrite > (?: ((?·?)∪{[]} = 𝐋 .|e^*|)); //;
639 nchange in match (𝐋 .|e^*|) with ((𝐋. |e|)^* ); napply sub_dot_star;##]
644 ∀S.∀e1,e2: pre S. 𝐋\p (e1 ⊙ e2) = 𝐋\p e1 · 𝐋 .|\fst e2| ∪ 𝐋\p e2.
645 #S e1 e2; napply odot_dot_aux; napply (bull_cup S (\fst e2)); nqed.
647 nlemma dot_star_epsilon : ∀S.∀e:re S.𝐋 e · 𝐋 e^* ∪ {[]} = 𝐋 e^*.
648 #S e; napply extP; #w; nnormalize; @;
649 ##[ *; ##[##2: #H; nrewrite < H; @[]; /3/] *; #w1; *; #w2;
650 *; *; #defw Hw1; *; #wl; *; #defw2 Hwl; @(w1 :: wl);
651 nrewrite < defw; nrewrite < defw2; @; //; @;//;
652 ##| *; #wl; *; #defw Hwl; ncases wl in defw Hwl; ##[#defw; #; @2; nrewrite < defw; //]
653 #x xs defw; *; #Hx Hxs; @; @x; @(flatten ? xs); nrewrite < defw;
657 nlemma nil_star : ∀S.∀e:re S. [ ] ∈ e^*.
658 #S e; @[]; /2/; nqed.
660 nlemma cupID : ∀S.∀l:word S → Prop.l ∪ l = l.
661 #S l; napply extP; #w; @; ##[*]//; #; @; //; nqed.
663 nlemma cup_star_nil : ∀S.∀l:word S → Prop. l^* ∪ {[]} = l^*.
664 #S a; napply extP; #w; @; ##[*; //; #H; nrewrite < H; @[]; @; //] #;@; //;nqed.
666 nlemma rcanc_sing : ∀S.∀A,C:word S → Prop.∀b:word S .
667 ¬ (A b) → A ∪ { (b) } = C → A = C - { (b) }.
668 #S A C b nbA defC; nrewrite < defC; napply extP; #w; @;
669 ##[ #Aw; /3/| *; *; //; #H nH; ncases nH; #abs; nlapply (abs H); *]
673 nlemma star_dot: ∀S.∀e:pre S. 𝐋\p (e^⊛) = 𝐋\p e · (𝐋 .|\fst e|)^*.
674 #S p; ncases p; #e b; ncases b;
675 ##[ nchange in match (〈e,true〉^⊛) with 〈?,?〉;
676 nletin e' ≝ (\fst (•e)); nletin b' ≝ (\snd (•e));
677 nchange in ⊢ (??%?) with (?∪?);
678 nchange in ⊢ (??(??%?)?) with (𝐋\p e' · 𝐋 .|e'|^* );
679 nrewrite > (?: 𝐋\p e' = 𝐋\p e ∪ (𝐋 .|e| - ϵ b' )); ##[##2:
680 nlapply (bull_cup ? e); #bc;
681 nchange in match (𝐋\p (•e)) in bc with (?∪?);
682 nchange in match b' in bc with b';
683 ncases b' in bc; ##[##2: nrewrite > (cup0…); nrewrite > (sub0…); //]
684 nrewrite > (cup_sub…); ##[napply rcanc_sing] //;##]
685 nrewrite > (cup_dotD…); nrewrite > (cupA…);nrewrite > (erase_bull…);
686 nrewrite > (sub_dot_star…);
687 nchange in match (𝐋\p 〈?,?〉) with (?∪?);
688 nrewrite > (cup_dotD…); nrewrite > (epsilon_dot…); //;
689 ##| nwhd in match (〈e,false〉^⊛); nchange in match (𝐋\p 〈?,?〉) with (?∪?);
691 nchange in ⊢ (??%?) with (𝐋\p e · 𝐋 .|e|^* );
692 nrewrite < (cup0 ? (𝐋\p e)); //;##]
695 nlet rec pre_of_re (S : Alpha) (e : re S) on e : pitem S ≝
700 | c e1 e2 ⇒ pc ? (pre_of_re ? e1) (pre_of_re ? e2)
701 | o e1 e2 ⇒ po ? (pre_of_re ? e1) (pre_of_re ? e2)
702 | k e1 ⇒ pk ? (pre_of_re ? e1)].
704 nlemma notFalse : ¬False. @; //; nqed.
706 nlemma dot0 : ∀S.∀A:word S → Prop. {} · A = {}.
707 #S A; nnormalize; napply extP; #w; @; ##[##2: *]
708 *; #w1; *; #w2; *; *; //; nqed.
710 nlemma Lp_pre_of_re : ∀S.∀e:re S. 𝐋\p (pre_of_re ? e) = {}.
711 #S e; nelim e; ##[##1,2,3: //]
712 ##[ #e1 e2 H1 H2; nchange in match (𝐋\p (pre_of_re S (e1 e2))) with (?∪?);
713 nrewrite > H1; nrewrite > H2; nrewrite > (dot0…); nrewrite > (cupID…);//
714 ##| #e1 e2 H1 H2; nchange in match (𝐋\p (pre_of_re S (e1+e2))) with (?∪?);
715 nrewrite > H1; nrewrite > H2; nrewrite > (cupID…); //
716 ##| #e1 H1; nchange in match (𝐋\p (pre_of_re S (e1^* ))) with (𝐋\p (pre_of_re ??) · ?);
717 nrewrite > H1; napply dot0; ##]
720 nlemma erase_pre_of_reK : ∀S.∀e. 𝐋 .|pre_of_re S e| = 𝐋 e.
722 ##[ #e1 e2 H1 H2; nchange in match (𝐋 (e1 · e2)) with (𝐋 e1·?);
723 nrewrite < H1; nrewrite < H2; //
724 ##| #e1 e2 H1 H2; nchange in match (𝐋 (e1 + e2)) with (𝐋 e1 ∪ ?);
725 nrewrite < H1; nrewrite < H2; //
726 ##| #e1 H1; nchange in match (𝐋 (e1^* )) with ((𝐋 e1)^* );
731 nlemma L_Lp_bull : ∀S.∀e:re S.𝐋 e = 𝐋\p (•pre_of_re ? e).
732 #S e; nrewrite > (bull_cup…); nrewrite > (Lp_pre_of_re…);
733 nrewrite > (cupC…); nrewrite > (cup0…); nrewrite > (erase_pre_of_reK…); //;
736 nlemma Pext : ∀S.∀f,g:word S → Prop. f = g → ∀w.f w → g w.
737 #S f g H; nrewrite > H; //; nqed.
740 ntheorem bull_true_epsilon : ∀S.∀e:pitem S. \snd (•e) = true ↔ [ ] ∈ .|e|.
742 ##[ #defsnde; nlapply (bull_cup ? e); nchange in match (𝐋\p (•e)) with (?∪?);
743 nrewrite > defsnde; #H;
744 nlapply (Pext ??? H [ ] ?); ##[ @2; //] *; //;
749 notation > "\move term 90 x term 90 E"
750 non associative with precedence 60 for @{move ? $x $E}.
751 nlet rec move (S: Alpha) (x:S) (E: pitem S) on E : pre S ≝
755 | ps y ⇒ 〈 `y, false 〉
756 | pp y ⇒ 〈 `y, x == y 〉
757 | po e1 e2 ⇒ \move x e1 ⊕ \move x e2
758 | pc e1 e2 ⇒ \move x e1 ⊙ \move x e2
759 | pk e ⇒ (\move x e)^⊛ ].
760 notation < "\move\shy x\shy E" non associative with precedence 60 for @{'move $x $E}.
761 notation > "\move term 90 x term 90 E" non associative with precedence 60 for @{'move $x $E}.
762 interpretation "move" 'move x E = (move ? x E).
764 ndefinition rmove ≝ λS:Alpha.λx:S.λe:pre S. \move x (\fst e).
765 interpretation "rmove" 'move x E = (rmove ? x E).
767 nlemma XXz : ∀S:Alpha.∀w:word S. w .∈ ∅ → False.
768 #S w abs; ninversion abs; #; ndestruct;
772 nlemma XXe : ∀S:Alpha.∀w:word S. w .∈ ϵ → False.
773 #S w abs; ninversion abs; #; ndestruct;
776 nlemma XXze : ∀S:Alpha.∀w:word S. w .∈ (∅ · ϵ) → False.
777 #S w abs; ninversion abs; #; ndestruct; /2/ by XXz,XXe;
782 ∀S.∀w:word S.∀x.∀E1,E2:pitem S. w .∈ \move x (E1 · E2) →
783 (∃w1.∃w2. w = w1@w2 ∧ w1 .∈ \move x E1 ∧ w2 ∈ .|E2|) ∨ w .∈ \move x E2.
784 #S w x e1 e2 H; nchange in H with (w .∈ \move x e1 ⊙ \move x e2);
785 ncases e1 in H; ncases e2;
786 ##[##1: *; ##[*; nnormalize; #; ndestruct]
787 #H; ninversion H; ##[##1,4,5,6: nnormalize; #; ndestruct]
788 nnormalize; #; ndestruct; ncases (?:False); /2/ by XXz,XXze;
789 ##|##2: *; ##[*; nnormalize; #; ndestruct]
790 #H; ninversion H; ##[##1,4,5,6: nnormalize; #; ndestruct]
791 nnormalize; #; ndestruct; ncases (?:False); /2/ by XXz,XXze;
792 ##| #r; *; ##[ *; nnormalize; #; ndestruct]
793 #H; ninversion H; ##[##1,4,5,6: nnormalize; #; ndestruct]
794 ##[##2: nnormalize; #; ndestruct; @2; @2; //.##]
795 nnormalize; #; ndestruct; ncases (?:False); /2/ by XXz;
796 ##| #y; *; ##[ *; nnormalize; #defw defx; ndestruct; @2; @1; /2/ by conj;##]
797 #H; ninversion H; nnormalize; #; ndestruct;
798 ##[ncases (?:False); /2/ by XXz] /3/ by or_intror;
799 ##| #r1 r2; *; ##[ *; #defw]
804 ∀S:Alpha.∀E:pre S.∀a,w.w .∈ \move a E ↔ (a :: w) .∈ E.
805 #S E; ncases E; #r b; nelim r;
807 ##[##1,3: nnormalize; *; ##[##1,3: *; #; ndestruct; ##| #abs; ncases (XXz … abs); ##]
808 #H; ninversion H; #; ndestruct;
809 ##|##*:nnormalize; *; ##[##1,3: *; #; ndestruct; ##| #H1; ncases (XXz … H1); ##]
810 #H; ninversion H; #; ndestruct;##]
811 ##|#a c w; @; nnormalize; ##[*; ##[*; #; ndestruct; ##] #abs; ninversion abs; #; ndestruct;##]
812 *; ##[##2: #abs; ninversion abs; #; ndestruct; ##] *; #; ndestruct;
813 ##|#a c w; @; nnormalize;
814 ##[ *; ##[ *; #defw; nrewrite > defw; #ca; @2; nrewrite > (eqb_t … ca); @; ##]
815 #H; ninversion H; #; ndestruct;
816 ##| *; ##[ *; #; ndestruct; ##] #H; ninversion H; ##[##2,3,4,5,6: #; ndestruct]
817 #d defw defa; ndestruct; @1; @; //; nrewrite > (eqb_true S d d); //. ##]
818 ##|#r1 r2 H1 H2 a w; @;
819 ##[ #H; ncases (in_move_cat … H);
820 ##[ *; #w1; *; #w2; *; *; #defw w1m w2m;
821 ncases (H1 a w1); #H1w1; #_; nlapply (H1w1 w1m); #good;
822 nrewrite > defw; @2; @2 (a::w1); //; ncases good; ##[ *; #; ndestruct] //.
831 notation > "x ↦* E" non associative with precedence 60 for @{move_star ? $x $E}.
832 nlet rec move_star (S : decidable) w E on w : bool × (pre S) ≝
835 | cons x w' ⇒ w' ↦* (x ↦ \snd E)].
837 ndefinition in_moves ≝ λS:decidable.λw.λE:bool × (pre S). \fst(w ↦* E).
839 ncoinductive equiv (S:decidable) : bool × (pre S) → bool × (pre S) → Prop ≝
841 ∀E1,E2: bool × (pre S).
843 (∀x. equiv S (x ↦ \snd E1) (x ↦ \snd E2)) →
846 ndefinition NAT: decidable.
850 include "hints_declaration.ma".
852 alias symbol "hint_decl" (instance 1) = "hint_decl_Type1".
853 unification hint 0 ≔ ; X ≟ NAT ⊢ carr X ≡ nat.
855 ninductive unit: Type[0] ≝ I: unit.
857 nlet corec foo_nop (b: bool):
859 〈 b, pc ? (ps ? 0) (pk ? (pc ? (ps ? 1) (ps ? 0))) 〉
860 〈 b, pc ? (pk ? (pc ? (ps ? 0) (ps ? 1))) (ps ? 0) 〉 ≝ ?.
862 [ nnormalize in ⊢ (??%%); napply (foo_nop false)
864 [ nnormalize in ⊢ (??%%); napply (foo_nop false)
865 | #w; nnormalize in ⊢ (??%%); napply (foo_nop false) ]##]
869 nlet corec foo (a: unit):
871 (eclose NAT (pc ? (ps ? 0) (pk ? (pc ? (ps ? 1) (ps ? 0)))))
872 (eclose NAT (pc ? (pk ? (pc ? (ps ? 0) (ps ? 1))) (ps ? 0)))
877 [ nnormalize in ⊢ (??%%);
878 nnormalize in foo: (? → ??%%);
880 [ nnormalize in ⊢ (??%%); napply foo_nop
882 [ nnormalize in ⊢ (??%%);
884 ##| #z; nnormalize in ⊢ (??%%); napply foo_nop ]##]
885 ##| #y; nnormalize in ⊢ (??%%); napply foo_nop
890 ndefinition test1 : pre ? ≝ ❨ `0 | `1 ❩^* `0.
891 ndefinition test2 : pre ? ≝ ❨ (`0`1)^* `0 | (`0`1)^* `1 ❩.
892 ndefinition test3 : pre ? ≝ (`0 (`0`1)^* `1)^*.
895 nlemma foo: in_moves ? [0;0;1;0;1;1] (ɛ test3) = true.
896 nnormalize in match test3;
901 (**********************************************************)
903 ninductive der (S: Type[0]) (a: S) : re S → re S → CProp[0] ≝
904 der_z: der S a (z S) (z S)
905 | der_e: der S a (e S) (z S)
906 | der_s1: der S a (s S a) (e ?)
907 | der_s2: ∀b. a ≠ b → der S a (s S b) (z S)
908 | der_c1: ∀e1,e2,e1',e2'. in_l S [] e1 → der S a e1 e1' → der S a e2 e2' →
909 der S a (c ? e1 e2) (o ? (c ? e1' e2) e2')
910 | der_c2: ∀e1,e2,e1'. Not (in_l S [] e1) → der S a e1 e1' →
911 der S a (c ? e1 e2) (c ? e1' e2)
912 | der_o: ∀e1,e2,e1',e2'. der S a e1 e1' → der S a e2 e2' →
913 der S a (o ? e1 e2) (o ? e1' e2').
915 nlemma eq_rect_CProp0_r:
916 ∀A.∀a,x.∀p:eq ? x a.∀P: ∀x:A. eq ? x a → CProp[0]. P a (refl A a) → P x p.
917 #A; #a; #x; #p; ncases p; #P; #H; nassumption.
920 nlemma append1: ∀A.∀a:A.∀l. [a] @ l = a::l. //. nqed.
922 naxiom in_l1: ∀S,r1,r2,w. in_l S [ ] r1 → in_l S w r2 → in_l S w (c S r1 r2).
923 (* #S; #r1; #r2; #w; nelim r1
925 | #H1; #H2; napply (in_c ? []); //
926 | (* tutti casi assurdi *) *)
928 ninductive in_l' (S: Type[0]) : word S → re S → CProp[0] ≝
929 in_l_empty1: ∀E.in_l S [] E → in_l' S [] E
930 | in_l_cons: ∀a,w,e,e'. in_l' S w e' → der S a e e' → in_l' S (a::w) e.
932 ncoinductive eq_re (S: Type[0]) : re S → re S → CProp[0] ≝
934 (in_l S [] E1 → in_l S [] E2) →
935 (in_l S [] E2 → in_l S [] E1) →
936 (∀a,E1',E2'. der S a E1 E1' → der S a E2 E2' → eq_re S E1' E2') →
939 (* serve il lemma dopo? *)
940 ntheorem eq_re_is_eq: ∀S.∀E1,E2. eq_re S E1 E2 → ∀w. in_l ? w E1 → in_l ? w E2.
941 #S; #E1; #E2; #H1; #w; #H2; nelim H2 in E2 H1 ⊢ %
943 | #a; #w; #R1; #R2; #K1; #K2; #K3; #R3; #K4; @2 R2; //; ncases K4;
945 (* IL VICEVERSA NON VALE *)
946 naxiom in_l_to_in_l: ∀S,w,E. in_l' S w E → in_l S w E.
947 (* #S; #w; #E; #H; nelim H
949 | #a; #w'; #r; #r'; #H1; (* e si cade qua sotto! *)
953 ntheorem der1: ∀S,a,e,e',w. der S a e e' → in_l S w e' → in_l S (a::w) e.
954 #S; #a; #E; #E'; #w; #H; nelim H
955 [##1,2: #H1; ninversion H1
956 [##1,8: #_; #K; (* non va ndestruct K; *) ncases (?:False); (* perche' due goal?*) /2/
957 |##2,9: #X; #Y; #K; ncases (?:False); /2/
958 |##3,10: #x; #y; #z; #w; #a; #b; #c; #d; #e; #K; ncases (?:False); /2/
959 |##4,11: #x; #y; #z; #w; #a; #b; #K; ncases (?:False); /2/
960 |##5,12: #x; #y; #z; #w; #a; #b; #K; ncases (?:False); /2/
961 |##6,13: #x; #y; #K; ncases (?:False); /2/
962 |##7,14: #x; #y; #z; #w; #a; #b; #c; #d; #K; ncases (?:False); /2/]
963 ##| #H1; ninversion H1
965 | #X; #Y; #K; ncases (?:False); /2/
966 | #x; #y; #z; #w; #a; #b; #c; #d; #e; #K; ncases (?:False); /2/
967 | #x; #y; #z; #w; #a; #b; #K; ncases (?:False); /2/
968 | #x; #y; #z; #w; #a; #b; #K; ncases (?:False); /2/
969 | #x; #y; #K; ncases (?:False); /2/
970 | #x; #y; #z; #w; #a; #b; #c; #d; #K; ncases (?:False); /2/ ]
971 ##| #H1; #H2; #H3; ninversion H3
972 [ #_; #K; ncases (?:False); /2/
973 | #X; #Y; #K; ncases (?:False); /2/
974 | #x; #y; #z; #w; #a; #b; #c; #d; #e; #K; ncases (?:False); /2/
975 | #x; #y; #z; #w; #a; #b; #K; ncases (?:False); /2/
976 | #x; #y; #z; #w; #a; #b; #K; ncases (?:False); /2/
977 | #x; #y; #K; ncases (?:False); /2/
978 | #x; #y; #z; #w; #a; #b; #c; #d; #K; ncases (?:False); /2/ ]
979 ##| #r1; #r2; #r1'; #r2'; #H1; #H2; #H3; #H4; #H5; #H6;