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.ma".
16 include "datatypes/bool.ma".
17 include "sets/sets.ma".
19 ninductive Admit : CProp[0] ≝ .
22 ninductive list (A:Type[0]) : Type[0] ≝
24 | cons: A -> list A -> list A.
26 nlet rec eq_list (A : setoid) (l1, l2 : list A) on l1 : CProp[0] ≝
28 [ nil ⇒ match l2 return λ_.CProp[0] with [ nil ⇒ True | _ ⇒ False ]
29 | cons x xs ⇒ match l2 with [ nil ⇒ False | cons y ys ⇒ x = y ∧ eq_list ? xs ys]].
31 ndefinition LIST : setoid → setoid.
32 #S; @(list S); @(eq_list S); ncases admit; nqed.
34 alias symbol "hint_decl" (instance 1) = "hint_decl_Type1".
35 unification hint 0 ≔ S : setoid;
36 P1 ≟ refl ? (eq0 (LIST S)),
37 P2 ≟ sym ? (eq0 (LIST S)),
38 P3 ≟ trans ? (eq0 (LIST S)),
39 X ≟ mk_setoid (list S) (mk_equivalence_relation ? (eq_list S) P1 P2 P3),
41 (*-----------------------------------------------------------------------*) ⊢
44 unification hint 0 ≔ S,a,b;
47 (* -------------------------------------------- *) ⊢
48 eq_list S a b ≡ eq_rel L (eq0 R) a b.
50 notation "hvbox(hd break :: tl)"
51 right associative with precedence 47
54 notation "[ list0 x sep ; ]"
55 non associative with precedence 90
56 for ${fold right @'nil rec acc @{'cons $x $acc}}.
58 notation "hvbox(l1 break @ l2)"
59 right associative with precedence 47
60 for @{'append $l1 $l2 }.
62 interpretation "nil" 'nil = (nil ?).
63 interpretation "cons" 'cons hd tl = (cons ? hd tl).
65 nlet rec append A (l1: list A) l2 on l1 ≝
68 | cons hd tl ⇒ hd :: append A tl l2 ].
70 interpretation "append" 'append l1 l2 = (append ? l1 l2).
72 ntheorem append_nil: ∀A:setoid.∀l:list A.l @ [] = l.
73 #A;#l;nelim l;//; #a;#l1;#IH;nnormalize;/2/;nqed.
75 ndefinition associative ≝ λA:setoid.λf:A → A → A.∀x,y,z.f x (f y z) = f (f x y) z.
78 ntheorem associative_append: ∀A:setoid.associative (list A) (append A).
79 #A;#x;#y;#z;nelim x[ napply # |#a;#x1;#H;nnormalize;/2/]nqed.
81 interpretation "iff" 'iff a b = (iff a b).
83 ninductive eq (A:Type[0]) (x:A) : A → CProp[0] ≝ refl: eq A x x.
85 nlemma eq_rect_Type0_r':
86 ∀A.∀a,x.∀p:eq ? x a.∀P: ∀x:A. eq ? x a → Type[0]. P a (refl A a) → P x p.
87 #A; #a; #x; #p; ncases p; #P; #H; nassumption.
90 nlemma eq_rect_Type0_r:
91 ∀A.∀a.∀P: ∀x:A. eq ? x a → Type[0]. P a (refl A a) → ∀x.∀p:eq ? x a.P x p.
92 #A; #a; #P; #p; #x0; #p0; napply (eq_rect_Type0_r' ??? p0); nassumption.
95 nlemma eq_rect_CProp0_r':
96 ∀A.∀a,x.∀p:eq ? x a.∀P: ∀x:A. eq ? x a → CProp[0]. P a (refl A a) → P x p.
97 #A; #a; #x; #p; ncases p; #P; #H; nassumption.
100 nlemma eq_rect_CProp0_r:
101 ∀A.∀a.∀P: ∀x:A. eq ? x a → CProp[0]. P a (refl A a) → ∀x.∀p:eq ? x a.P x p.
102 #A; #a; #P; #p; #x0; #p0; napply (eq_rect_CProp0_r' ??? p0); nassumption.
105 notation < "a = b" non associative with precedence 45 for @{ 'eqpp $a $b}.
106 interpretation "bool eq" 'eqpp a b = (eq bool a b).
108 ndefinition BOOL : setoid.
109 @bool; @(eq bool); ncases admit.nqed.
111 alias symbol "hint_decl" (instance 1) = "hint_decl_Type1".
112 alias id "refl" = "cic:/matita/ng/properties/relations/refl.fix(0,1,3)".
113 unification hint 0 ≔ ;
114 P1 ≟ refl ? (eq0 BOOL),
115 P2 ≟ sym ? (eq0 BOOL),
116 P3 ≟ trans ? (eq0 BOOL),
117 X ≟ mk_setoid bool (mk_equivalence_relation ? (eq bool) P1 P2 P3)
118 (*-----------------------------------------------------------------------*) ⊢
121 unification hint 0 ≔ a,b;
124 (* -------------------------------------------- *) ⊢
125 eq bool a b ≡ eq_rel L (eq0 R) a b.
127 nrecord Alpha : Type[1] ≝ {
129 eqb: acarr → acarr → bool;
130 eqb_true: ∀x,y. (eqb x y = true) = (x = y)
133 notation "a == b" non associative with precedence 45 for @{ 'eqb $a $b }.
134 interpretation "eqb" 'eqb a b = (eqb ? a b).
136 ninductive re (S: Type[0]) : Type[0] ≝
140 | c: re S → re S → re S
141 | o: re S → re S → re S
144 naxiom eq_re : ∀S:Alpha.re S → re S → CProp[0].
145 ndefinition RE : Alpha → setoid.
146 #A; @(re A); @(eq_re A); ncases admit. nqed.
148 alias symbol "hint_decl" (instance 1) = "hint_decl_Type1".
149 alias id "carr" = "cic:/matita/ng/sets/setoids/carr.fix(0,0,1)".
150 unification hint 0 ≔ A : Alpha;
151 P1 ≟ refl ? (eq0 (RE A)),
152 P2 ≟ sym ? (eq0 (RE A)),
153 P3 ≟ trans ? (eq0 (RE A)),
154 X ≟ mk_setoid (re A) (mk_equivalence_relation ? (eq_re A) P1 P2 P3),
156 (*-----------------------------------------------------------------------*) ⊢
159 unification hint 0 ≔ A,a,b;
162 (* -------------------------------------------- *) ⊢
163 eq_re A a b ≡ eq_rel L (eq0 R) a b.
165 notation < "a \sup ⋇" non associative with precedence 90 for @{ 'pk $a}.
166 notation > "a ^ *" non associative with precedence 75 for @{ 'pk $a}.
167 interpretation "star" 'pk a = (k ? a).
168 interpretation "or" 'plus a b = (o ? a b).
170 notation "a · b" non associative with precedence 60 for @{ 'pc $a $b}.
171 interpretation "cat" 'pc a b = (c ? a b).
173 (* to get rid of \middot *)
174 ncoercion c : ∀S.∀p:re S. re S → re S ≝ c on _p : re ? to ∀_:?.?.
176 notation < "a" non associative with precedence 90 for @{ 'ps $a}.
177 notation > "` term 90 a" non associative with precedence 90 for @{ 'ps $a}.
178 interpretation "atom" 'ps a = (s ? a).
180 notation "ϵ" non associative with precedence 90 for @{ 'epsilon }.
181 interpretation "epsilon" 'epsilon = (e ?).
183 notation "0" non associative with precedence 90 for @{ 'empty_r }.
184 interpretation "empty" 'empty_r = (z ?).
186 notation > "'lang' S" non associative with precedence 90 for @{ Ω^(list $S) }.
187 notation > "'Elang' S" non associative with precedence 90 for @{ 𝛀^(list $S) }.
189 nlet rec flatten S (l : list (list S)) on l : list S ≝
190 match l with [ nil ⇒ [ ] | cons w tl ⇒ w @ flatten ? tl ].
192 nlet rec conjunct S (l : list (list S)) (L : lang S) on l: CProp[0] ≝
193 match l with [ nil ⇒ True | cons w tl ⇒ w ∈ L ∧ conjunct ? tl L ].
195 ndefinition sing_lang : ∀A:setoid.∀x:A.Ω^A ≝ λS.λx.{ w | x = w }.
196 interpretation "sing lang" 'singl x = (sing_lang ? x).
198 interpretation "subset construction with type" 'comprehension t \eta.x =
201 ndefinition cat : ∀A:setoid.∀l1,l2:lang A.lang A ≝
202 λS.λl1,l2.{ w ∈ list S | ∃w1,w2.w =_0 w1 @ w2 ∧ w1 ∈ l1 ∧ w2 ∈ l2}.
203 interpretation "cat lang" 'pc a b = (cat ? a b).
205 ndefinition star : ∀A:setoid.∀l:lang A.lang A ≝
206 λS.λl.{ w ∈ list S | ∃lw.flatten ? lw = w ∧ conjunct ? lw l}.
207 interpretation "star lang" 'pk l = (star ? l).
209 notation > "𝐋 term 70 E" non associative with precedence 75 for @{L_re ? $E}.
210 nlet rec L_re (S : Alpha) (r : re S) on r : lang S ≝
215 | c r1 r2 ⇒ 𝐋 r1 · 𝐋 r2
216 | o r1 r2 ⇒ 𝐋 r1 ∪ 𝐋 r2
218 notation "𝐋 term 70 E" non associative with precedence 75 for @{'L_re $E}.
219 interpretation "in_l" 'L_re E = (L_re ? E).
221 notation "a || b" left associative with precedence 30 for @{'orb $a $b}.
222 ndefinition orb ≝ λa,b:bool. match a with [ true ⇒ true | _ ⇒ b ].
223 interpretation "orb" 'orb a b = (orb a b).
225 ninductive pitem (S: Type[0]) : Type[0] ≝
230 | pc: pitem S → pitem S → pitem S
231 | po: pitem S → pitem S → pitem S
232 | pk: pitem S → pitem S.
234 ndefinition pre ≝ λS.pitem S × bool.
236 notation "\fst term 90 x" non associative with precedence 90 for @{'fst $x}.
237 interpretation "fst" 'fst x = (fst ? ? x).
238 notation > "\snd term 90 x" non associative with precedence 90 for @{'snd $x}.
239 interpretation "snd" 'snd x = (snd ? ? x).
241 interpretation "pstar" 'pk a = (pk ? a).
242 interpretation "por" 'plus a b = (po ? a b).
243 interpretation "pcat" 'pc a b = (pc ? a b).
244 notation < ".a" non associative with precedence 90 for @{ 'pp $a}.
245 notation > "`. term 90 a" non associative with precedence 90 for @{ 'pp $a}.
246 interpretation "ppatom" 'pp a = (pp ? a).
247 (* to get rid of \middot *)
248 ncoercion pc : ∀S.∀p:pitem S. pitem S → pitem S ≝ pc on _p : pitem ? to ∀_:?.?.
249 interpretation "patom" 'ps a = (ps ? a).
250 interpretation "pepsilon" 'epsilon = (pe ?).
251 interpretation "pempty" 'empty_r = (pz ?).
253 notation > "|term 19 e|" non associative with precedence 70 for @{forget ? $e}.
254 nlet rec forget (S: Alpha) (l : pitem S) on l: re S ≝
260 | pc E1 E2 ⇒ (|E1| · |E2|)
261 | po E1 E2 ⇒ (|E1| + |E2|)
263 notation < "|term 19 e|" non associative with precedence 70 for @{'forget $e}.
264 interpretation "forget" 'forget a = (forget ? a).
266 notation > "𝐋\p\ term 70 E" non associative with precedence 75 for @{L_pi ? $E}.
267 nlet rec L_pi (S : Alpha) (r : pitem S) on r : lang S ≝
273 | pc r1 r2 ⇒ 𝐋\p\ r1 · 𝐋 |r2| ∪ 𝐋\p\ r2
274 | po r1 r2 ⇒ 𝐋\p\ r1 ∪ 𝐋\p\ r2
275 | pk r1 ⇒ 𝐋\p\ r1 · 𝐋 (|r1|^* ) ].
276 notation > "𝐋\p term 70 E" non associative with precedence 75 for @{'L_pi $E}.
277 notation "𝐋\sub(\p) term 70 E" non associative with precedence 75 for @{'L_pi $E}.
278 interpretation "in_pl" 'L_pi E = (L_pi ? E).
280 (* The caml, as some patches for it *)
281 ncoercion setoid1_of_setoid : ∀s:setoid. setoid1 ≝ setoid1_of_setoid on _s: setoid to setoid1.
283 alias symbol "hint_decl" (instance 1) = "hint_decl_CProp2".
284 unification hint 0 ≔ S : setoid, x,y;
286 TT ≟ setoid1_of_setoid SS
287 (*-----------------------------------------*) ⊢
288 eq_list S x y ≡ eq_rel1 ? (eq1 TT) x y.
290 unification hint 0 ≔ SS : setoid;
292 TT ≟ setoid1_of_setoid (LIST SS)
293 (*-----------------------------------------------------------------*) ⊢
296 (* Ex setoid support *)
297 nlemma Sig: ∀S,T:setoid.∀P: S → (T → CPROP).
298 ∀y,z:T.y = z → (∀x.y=z → P x y = P x z) → (Ex S (λx.P x y)) =_1 (Ex S (λx.P x z)).
299 #S T P y z Q E; @; *; #x Px; @x; nlapply (E x Q); *; /2/; nqed.
301 notation "∑" non associative with precedence 90 for @{Sig ?????}.
303 nlemma test : ∀S:setoid. ∀ee: S ⇒_1 S ⇒_1 CPROP.
304 ∀x,y:setoid1_of_setoid S.x =_1 y → (Ex S (λw.ee x w ∧ True)) =_1 (Ex S (λw.ee y w ∧ True)).
306 napply (.=_1 (∑ E (λw,H.(H ╪_1 #)╪_1 #))).
310 nlemma test2 : ∀S:setoid. ∀ee: S ⇒_1 S ⇒_1 CPROP.
311 ∀x,y:setoid1_of_setoid S.x =_1 y →
312 (True ∧ (Ex S (λw.ee x w ∧ True))) =_1 (True ∧ (Ex S (λw.ee y w ∧ True))).
314 napply (.=_1 #╪_1(∑ E (λw,H.(H ╪_1 #) ╪_1 #))).
318 nlemma ex_setoid : ∀S:setoid.(S ⇒_1 CPROP) → setoid.
319 #T P; @ (Ex T (λx:T.P x)); @;
320 ##[ #H1 H2; napply True |##*: //; ##]
323 unification hint 0 ≔ T,P ; S ≟ (ex_setoid T P) ⊢
324 Ex T (λx:T.P x) ≡ carr S.
326 nlemma test3 : ∀S:setoid. ∀ee: S ⇒_1 S ⇒_1 CPROP.
327 ∀x,y:setoid1_of_setoid S.x =_1 y →
328 ((Ex S (λw.ee x w ∧ True) ∨ True)) =_1 ((Ex S (λw.ee y w ∧ True) ∨ True)).
330 napply (.=_1 (∑ E (λw,H.(H ╪_1 #) ╪_1 #)) ╪_1 #).
333 (* Ex setoid support end *)
335 ndefinition L_pi_ext : ∀S:Alpha.∀r:pitem S.Elang S.
336 #S r; @(𝐋\p r); #w1 w2 E; nelim r;
340 ##| #x; @; #H; nchange in H with ([?] =_0 ?); ##[ napply ((.=_0 H) E); ##]
341 napply ((.=_0 H) E^-1);
343 nchange in match (w1 ∈ 𝐋\p (?·?)) with ((∃_.?)∨?);
344 nchange in match (w2 ∈ 𝐋\p (?·?)) with ((∃_.?)∨?);
346 napply (.=_1 (∑ E (λx1,H1.∑ E (λx2,H2.?)))╪_1 #); ##[
347 ncut ((w1 = (x1@x2)) = (w2 = (x1@x2)));##[
348 @; #X; ##[ napply ((.= H1^-1) X) | napply ((.= H2) X) ] ##] #X;
349 napply ( (X‡#)‡#); ##]
352 nnormalize in ⊢ (???%%);
354 ##| #e H; nnormalize in ⊢ (???%%);
355 napply (.=_1 (∑ E (λx1,H1.∑ E (λx2,H2.?)))); ##[
356 ncut ((w1 = (x1@x2)) = (w2 = (x1@x2)));##[
357 @; #X; ##[ napply ((.= H1^-1) X) | napply ((.= H2) X) ] ##] #X;
358 napply ((X‡#)‡#); ##]
362 unification hint 0 ≔ S : Alpha,e : pitem S;
364 X ≟ (mk_ext_powerclass SS (𝐋\p e) (ext_prop SS (L_pi_ext S e)))
365 (*-----------------------------------------------------------------*)⊢
366 ext_carr SS X ≡ 𝐋\p e.
368 ndefinition epsilon ≝
369 λS:Alpha.λb.match b return λ_.lang S with [ true ⇒ { [ ] } | _ ⇒ ∅ ].
371 interpretation "epsilon" 'epsilon = (epsilon ?).
372 notation < "ϵ b" non associative with precedence 90 for @{'app_epsilon $b}.
373 interpretation "epsilon lang" 'app_epsilon b = (epsilon ? b).
375 ndefinition L_pr ≝ λS : Alpha.λp:pre S. 𝐋\p\ (\fst p) ∪ ϵ (\snd p).
377 interpretation "L_pr" 'L_pi E = (L_pr ? E).
379 nlemma append_eq_nil : ∀S:setoid.∀w1,w2:list S. [ ] = w1 @ w2 → w1 = [ ].
380 #S w1; ncases w1; //. nqed.
383 nlemma epsilon_in_true : ∀S:Alpha.∀e:pre S. [ ] ∈ 𝐋\p e = (\snd e = true).
384 #S r; ncases r; #e b; @; ##[##2: #H; nrewrite > H; @2; /2/; ##] ncases b;//;
385 *; ##[##2:*] nelim e;
386 ##[ ##1,2: *; ##| #c; *; ##| #c; *| ##7: #p H;
387 ##| #r1 r2 H G; *; ##[##2: nassumption; ##]
388 ##| #r1 r2 H1 H2; *; /2/ by {}]
389 *; #w1; *; #w2; *; *;
390 ##[ #defw1 H1 foo; napply H;
391 napply (. (append_eq_nil ? ?? defw1)^-1╪_1#);
393 ##| #defw1 H1 foo; napply H;
394 napply (. (append_eq_nil ? ?? defw1)^-1╪_1#);
399 nlemma not_epsilon_lp : ∀S:Alpha.∀e:pitem S. ¬ ([ ] ∈ (𝐋\p e)).
400 #S e; nelim e; ##[##1,2,3,4: nnormalize;/2/]
401 ##[ #p1 p2 np1 np2; *; ##[##2: napply np2] *; #w1; *; #w2; *; *; #abs;
402 nlapply (append_eq_nil ??? abs); # defw1; #; napply np1;
403 napply (. defw1^-1╪_1#);
405 ##| #p1 p2 np1 np2; *; nchange with (¬?); //;
406 ##| #r n; *; #w1; *; #w2; *; *; #abs; #; napply n;
407 nlapply (append_eq_nil ??? abs); # defw1; #;
408 napply (. defw1^-1╪_1#);
412 ndefinition lo ≝ λS:Alpha.λa,b:pre S.〈\fst a + \fst b,\snd a || \snd b〉.
413 notation "a ⊕ b" left associative with precedence 60 for @{'oplus $a $b}.
414 interpretation "oplus" 'oplus a b = (lo ? a b).
416 ndefinition lc ≝ λS:Alpha.λbcast:∀S:Alpha.∀E:pitem S.pre S.λa,b:pre S.
417 match a with [ mk_pair e1 b1 ⇒
419 [ false ⇒ 〈e1 · \fst b, \snd b〉
420 | true ⇒ 〈e1 · \fst (bcast ? (\fst b)),\snd b || \snd (bcast ? (\fst b))〉]].
422 notation < "a ⊙ b" left associative with precedence 60 for @{'lc $op $a $b}.
423 interpretation "lc" 'lc op a b = (lc ? op a b).
424 notation > "a ⊙ b" left associative with precedence 60 for @{'lc eclose $a $b}.
426 ndefinition lk ≝ λS:Alpha.λbcast:∀S:Alpha.∀E:pitem S.pre S.λa:pre S.
427 match a with [ mk_pair e1 b1 ⇒
429 [ false ⇒ 〈e1^*, false〉
430 | true ⇒ 〈(\fst (bcast ? e1))^*, true〉]].
432 notation < "a \sup ⊛" non associative with precedence 90 for @{'lk $op $a}.
433 interpretation "lk" 'lk op a = (lk ? op a).
434 notation > "a ^ ⊛" non associative with precedence 75 for @{'lk eclose $a}.
436 notation > "•" non associative with precedence 60 for @{eclose ?}.
437 nlet rec eclose (S: Alpha) (E: pitem S) on E : pre S ≝
441 | ps x ⇒ 〈 `.x, false 〉
442 | pp x ⇒ 〈 `.x, false 〉
443 | po E1 E2 ⇒ •E1 ⊕ •E2
444 | pc E1 E2 ⇒ •E1 ⊙ 〈 E2, false 〉
445 | pk E ⇒ 〈(\fst (•E))^*,true〉].
446 notation < "• x" non associative with precedence 60 for @{'eclose $x}.
447 interpretation "eclose" 'eclose x = (eclose ? x).
448 notation > "• x" non associative with precedence 60 for @{'eclose $x}.
450 ndefinition reclose ≝ λS:Alpha.λp:pre S.let p' ≝ •\fst p in 〈\fst p',\snd p || \snd p'〉.
451 interpretation "reclose" 'eclose x = (reclose ? x).
453 nlemma epsilon_or : ∀S:Alpha.∀b1,b2. ϵ(b1 || b2) = ϵ b1 ∪ ϵ b2. ##[##2: napply S]
454 #S b1 b2; ncases b1; ncases b2;
455 nchange in match (true || true) with true;
456 nchange in match (true || false) with true;
457 nchange in match (ϵ true) with {[]};
458 nchange in match (ϵ false) with ∅;
459 ##[##1,4: napply ((cupID…)^-1);
460 ##| napply ((cup0 ? {[]})^-1);
461 ##| napply (.= (cup0 ? {[]})^-1); napply cupC; ##]
464 (* XXX move somewere else *)
465 ndefinition if': ∀A,B:CPROP. A = B → A → B.
468 ncoercion if : ∀A,B:CPROP. ∀p:A = B. A → B ≝ if' on _p : eq_rel1 ???? to ∀_:?.?.
471 nlemma oplus_cup : ∀S:Alpha.∀e1,e2:pre S.𝐋\p (e1 ⊕ e2) = 𝐋\p e1 ∪ 𝐋\p e2.
472 #S r1; ncases r1; #e1 b1 r2; ncases r2; #e2 b2;
473 nwhd in ⊢ (???(??%)?);
474 nchange in ⊢(???%?) with (𝐋\p (e1 + e2) ∪ ϵ (b1 || b2));
475 nchange in ⊢(???(??%?)?) with (𝐋\p (e1) ∪ 𝐋\p (e2));
476 napply (.=_1 #╪_1 (epsilon_or ???));
477 napply (.=_1 (cupA…)^-1);
478 napply (.=_1 (cupA…)╪_1#);
479 napply (.=_1 (#╪_1(cupC…))╪_1#);
480 napply (.=_1 (cupA…)^-1╪_1#);
481 napply (.=_1 (cupA…));
487 manca setoide per pair (e pre)
490 ∀S:Alpha.∀e1,e2:pitem S.∀b2. 〈e1,true〉 ⊙ 〈e2,b2〉 = ?.〈e1 · \fst (•e2),b2 || \snd (•e2)〉.
491 #S e1 e2 b2; nnormalize; ncases (•e2); //; nqed.
493 nlemma LcatE : ∀S.∀e1,e2:pitem S.𝐋\p (e1 · e2) = 𝐋\p e1 · 𝐋 .|e2| ∪ 𝐋\p e2. //; nqed.
495 nlemma cup_dotD : ∀S.∀p,q,r:lang S.(p ∪ q) · r = (p · r) ∪ (q · r).
496 #S p q r; napply extP; #w; nnormalize; @;
497 ##[ *; #x; *; #y; *; *; #defw; *; /7/ by or_introl, or_intror, ex_intro, conj;
498 ##| *; *; #x; *; #y; *; *; /7/ by or_introl, or_intror, ex_intro, conj; ##]
502 nlemma erase_dot : ∀S.∀e1,e2:pitem S.𝐋 .|e1 · e2| = 𝐋 .|e1| · 𝐋 .|e2|.
503 #S e1 e2; napply extP; nnormalize; #w; @; *; #w1; *; #w2; *; *; /7/ by ex_intro, conj;
506 nlemma erase_plus : ∀S.∀e1,e2:pitem S.𝐋 .|e1 + e2| = 𝐋 .|e1| ∪ 𝐋 .|e2|.
507 #S e1 e2; napply extP; nnormalize; #w; @; *; /4/ by or_introl, or_intror; nqed.
509 nlemma erase_star : ∀S.∀e1:pitem S.𝐋 .|e1|^* = 𝐋 .|e1^*|. //; nqed.
511 ndefinition substract := λS.λp,q:word S → Prop.λw.p w ∧ ¬ q w.
512 interpretation "substract" 'minus a b = (substract ? a b).
514 nlemma cup_sub: ∀S.∀a,b:word S → Prop. ¬ (a []) → a ∪ (b - {[]}) = (a ∪ b) - {[]}.
515 #S a b c; napply extP; #w; nnormalize; @; *; /4/; *; /4/; nqed.
517 nlemma sub0 : ∀S.∀a:word S → Prop. a - {} = a.
518 #S a; napply extP; #w; nnormalize; @; /3/; *; //; nqed.
520 nlemma subK : ∀S.∀a:word S → Prop. a - a = {}.
521 #S a; napply extP; #w; nnormalize; @; *; /2/; nqed.
523 nlemma subW : ∀S.∀a,b:word S → Prop.∀w.(a - b) w → a w.
524 #S a b w; nnormalize; *; //; nqed.
526 nlemma erase_bull : ∀S.∀a:pitem S. .|\fst (•a)| = .|a|.
527 #S a; nelim a; // by {};
528 ##[ #e1 e2 IH1 IH2; nchange in ⊢ (???%) with (.|e1| · .|e2|);
529 nrewrite < IH1; nrewrite < IH2;
530 nchange in ⊢ (??(??%)?) with (\fst (•e1 ⊙ 〈e2,false〉));
531 ncases (•e1); #e3 b; ncases b; nnormalize;
532 ##[ ncases (•e2); //; ##| nrewrite > IH2; //]
533 ##| #e1 e2 IH1 IH2; nchange in ⊢ (???%) with (.|e1| + .|e2|);
534 nrewrite < IH2; nrewrite < IH1;
535 nchange in ⊢ (??(??%)?) with (\fst (•e1 ⊕ •e2));
536 ncases (•e1); ncases (•e2); //;
537 ##| #e IH; nchange in ⊢ (???%) with (.|e|^* ); nrewrite < IH;
538 nchange in ⊢ (??(??%)?) with (\fst (•e))^*; //; ##]
541 nlemma eta_lp : ∀S.∀p:pre S.𝐋\p p = 𝐋\p 〈\fst p, \snd p〉.
542 #S p; ncases p; //; nqed.
544 nlemma epsilon_dot: ∀S.∀p:word S → Prop. {[]} · p = p.
545 #S e; napply extP; #w; nnormalize; @; ##[##2: #Hw; @[]; @w; /3/; ##]
546 *; #w1; *; #w2; *; *; #defw defw1 Hw2; nrewrite < defw; nrewrite < defw1;
549 (* theorem 16: 1 → 3 *)
550 nlemma odot_dot_aux : ∀S.∀e1,e2: pre S.
551 𝐋\p (•(\fst e2)) = 𝐋\p (\fst e2) ∪ 𝐋 .|\fst e2| →
552 𝐋\p (e1 ⊙ e2) = 𝐋\p e1 · 𝐋 .|\fst e2| ∪ 𝐋\p e2.
553 #S e1 e2 th1; ncases e1; #e1' b1'; ncases b1';
554 ##[ nwhd in ⊢ (??(??%)?); nletin e2' ≝ (\fst e2); nletin b2' ≝ (\snd e2);
555 nletin e2'' ≝ (\fst (•(\fst e2))); nletin b2'' ≝ (\snd (•(\fst e2)));
556 nchange in ⊢ (??%?) with (?∪?);
557 nchange in ⊢ (??(??%?)?) with (?∪?);
558 nchange in match (𝐋\p 〈?,?〉) with (?∪?);
559 nrewrite > (epsilon_or …); nrewrite > (cupC ? (ϵ ?)…);
560 nrewrite > (cupA …);nrewrite < (cupA ?? (ϵ?)…);
561 nrewrite > (?: 𝐋\p e2'' ∪ ϵ b2'' = 𝐋\p e2' ∪ 𝐋 .|e2'|); ##[##2:
562 nchange with (𝐋\p 〈e2'',b2''〉 = 𝐋\p e2' ∪ 𝐋 .|e2'|);
563 ngeneralize in match th1;
564 nrewrite > (eta_lp…); #th1; nrewrite > th1; //;##]
565 nrewrite > (eta_lp ? e2);
566 nchange in match (𝐋\p 〈\fst e2,?〉) with (𝐋\p e2'∪ ϵ b2');
567 nrewrite > (cup_dotD …); nrewrite > (epsilon_dot…);
568 nrewrite > (cupC ? (𝐋\p e2')…); nrewrite > (cupA…);nrewrite > (cupA…);
569 nrewrite < (erase_bull S e2') in ⊢ (???(??%?)); //;
570 ##| ncases e2; #e2' b2'; nchange in match (〈e1',false〉⊙?) with 〈?,?〉;
571 nchange in match (𝐋\p ?) with (?∪?);
572 nchange in match (𝐋\p (e1'·?)) with (?∪?);
573 nchange in match (𝐋\p 〈e1',?〉) with (?∪?);
575 nrewrite > (cupA…); //;##]
578 nlemma sub_dot_star :
579 ∀S.∀X:word S → Prop.∀b. (X - ϵ b) · X^* ∪ {[]} = X^*.
580 #S X b; napply extP; #w; @;
581 ##[ *; ##[##2: nnormalize; #defw; nrewrite < defw; @[]; @; //]
582 *; #w1; *; #w2; *; *; #defw sube; *; #lw; *; #flx cj;
583 @ (w1 :: lw); nrewrite < defw; nrewrite < flx; @; //;
584 @; //; napply (subW … sube);
585 ##| *; #wl; *; #defw Pwl; nrewrite < defw; nelim wl in Pwl; ##[ #_; @2; //]
586 #w' wl' IH; *; #Pw' IHp; nlapply (IH IHp); *;
587 ##[ *; #w1; *; #w2; *; *; #defwl' H1 H2;
588 @; ncases b in H1; #H1;
589 ##[##2: nrewrite > (sub0…); @w'; @(w1@w2);
590 nrewrite > (associative_append ? w' w1 w2);
591 nrewrite > defwl'; @; ##[@;//] @(wl'); @; //;
592 ##| ncases w' in Pw';
593 ##[ #ne; @w1; @w2; nrewrite > defwl'; @; //; @; //;
594 ##| #x xs Px; @(x::xs); @(w1@w2);
595 nrewrite > (defwl'); @; ##[@; //; @; //; @; nnormalize; #; ndestruct]
597 ##| #wlnil; nchange in match (flatten ? (w'::wl')) with (w' @ flatten ? wl');
598 nrewrite < (wlnil); nrewrite > (append_nil…); ncases b;
599 ##[ ncases w' in Pw'; /2/; #x xs Pxs; @; @(x::xs); @([]);
600 nrewrite > (append_nil…); @; ##[ @; //;@; //; nnormalize; @; #; ndestruct]
602 ##| @; @w'; @[]; nrewrite > (append_nil…); @; ##[##2: @[]; @; //]
603 @; //; @; //; @; *;##]##]##]
607 alias symbol "pc" (instance 13) = "cat lang".
608 alias symbol "in_pl" (instance 23) = "in_pl".
609 alias symbol "in_pl" (instance 5) = "in_pl".
610 alias symbol "eclose" (instance 21) = "eclose".
611 ntheorem bull_cup : ∀S:Alpha. ∀e:pitem S. 𝐋\p (•e) = 𝐋\p e ∪ 𝐋 .|e|.
613 ##[ #a; napply extP; #w; nnormalize; @; *; /3/ by or_introl, or_intror;
614 ##| #a; napply extP; #w; nnormalize; @; *; /3/ by or_introl; *;
616 nchange in ⊢ (??(??(%))?) with (•e1 ⊙ 〈e2,false〉);
617 nrewrite > (odot_dot_aux S (•e1) 〈e2,false〉 IH2);
618 nrewrite > (IH1 …); nrewrite > (cup_dotD …);
619 nrewrite > (cupA …); nrewrite > (cupC ?? (𝐋\p ?) …);
620 nchange in match (𝐋\p 〈?,?〉) with (𝐋\p e2 ∪ {}); nrewrite > (cup0 …);
621 nrewrite < (erase_dot …); nrewrite < (cupA …); //;
623 nchange in match (•(?+?)) with (•e1 ⊕ •e2); nrewrite > (oplus_cup …);
624 nrewrite > (IH1 …); nrewrite > (IH2 …); nrewrite > (cupA …);
625 nrewrite > (cupC ? (𝐋\p e2)…);nrewrite < (cupA ??? (𝐋\p e2)…);
626 nrewrite > (cupC ?? (𝐋\p e2)…); nrewrite < (cupA …);
627 nrewrite < (erase_plus …); //.
628 ##| #e; nletin e' ≝ (\fst (•e)); nletin b' ≝ (\snd (•e)); #IH;
629 nchange in match (𝐋\p ?) with (𝐋\p 〈e'^*,true〉);
630 nchange in match (𝐋\p ?) with (𝐋\p (e'^* ) ∪ {[ ]});
631 nchange in ⊢ (??(??%?)?) with (𝐋\p e' · 𝐋 .|e'|^* );
632 nrewrite > (erase_bull…e);
633 nrewrite > (erase_star …);
634 nrewrite > (?: 𝐋\p e' = 𝐋\p e ∪ (𝐋 .|e| - ϵ b')); ##[##2:
635 nchange in IH : (??%?) with (𝐋\p e' ∪ ϵ b'); ncases b' in IH;
636 ##[ #IH; nrewrite > (cup_sub…); //; nrewrite < IH;
637 nrewrite < (cup_sub…); //; nrewrite > (subK…); nrewrite > (cup0…);//;
638 ##| nrewrite > (sub0 …); #IH; nrewrite < IH; nrewrite > (cup0 …);//; ##]##]
639 nrewrite > (cup_dotD…); nrewrite > (cupA…);
640 nrewrite > (?: ((?·?)∪{[]} = 𝐋 .|e^*|)); //;
641 nchange in match (𝐋 .|e^*|) with ((𝐋. |e|)^* ); napply sub_dot_star;##]
646 ∀S.∀e1,e2: pre S. 𝐋\p (e1 ⊙ e2) = 𝐋\p e1 · 𝐋 .|\fst e2| ∪ 𝐋\p e2.
647 #S e1 e2; napply odot_dot_aux; napply (bull_cup S (\fst e2)); nqed.
649 nlemma dot_star_epsilon : ∀S.∀e:re S.𝐋 e · 𝐋 e^* ∪ {[]} = 𝐋 e^*.
650 #S e; napply extP; #w; nnormalize; @;
651 ##[ *; ##[##2: #H; nrewrite < H; @[]; /3/] *; #w1; *; #w2;
652 *; *; #defw Hw1; *; #wl; *; #defw2 Hwl; @(w1 :: wl);
653 nrewrite < defw; nrewrite < defw2; @; //; @;//;
654 ##| *; #wl; *; #defw Hwl; ncases wl in defw Hwl; ##[#defw; #; @2; nrewrite < defw; //]
655 #x xs defw; *; #Hx Hxs; @; @x; @(flatten ? xs); nrewrite < defw;
659 nlemma nil_star : ∀S.∀e:re S. [ ] ∈ e^*.
660 #S e; @[]; /2/; nqed.
662 nlemma cupID : ∀S.∀l:word S → Prop.l ∪ l = l.
663 #S l; napply extP; #w; @; ##[*]//; #; @; //; nqed.
665 nlemma cup_star_nil : ∀S.∀l:word S → Prop. l^* ∪ {[]} = l^*.
666 #S a; napply extP; #w; @; ##[*; //; #H; nrewrite < H; @[]; @; //] #;@; //;nqed.
668 nlemma rcanc_sing : ∀S.∀A,C:word S → Prop.∀b:word S .
669 ¬ (A b) → A ∪ { (b) } = C → A = C - { (b) }.
670 #S A C b nbA defC; nrewrite < defC; napply extP; #w; @;
671 ##[ #Aw; /3/| *; *; //; #H nH; ncases nH; #abs; nlapply (abs H); *]
675 nlemma star_dot: ∀S.∀e:pre S. 𝐋\p (e^⊛) = 𝐋\p e · (𝐋 .|\fst e|)^*.
676 #S p; ncases p; #e b; ncases b;
677 ##[ nchange in match (〈e,true〉^⊛) with 〈?,?〉;
678 nletin e' ≝ (\fst (•e)); nletin b' ≝ (\snd (•e));
679 nchange in ⊢ (??%?) with (?∪?);
680 nchange in ⊢ (??(??%?)?) with (𝐋\p e' · 𝐋 .|e'|^* );
681 nrewrite > (?: 𝐋\p e' = 𝐋\p e ∪ (𝐋 .|e| - ϵ b' )); ##[##2:
682 nlapply (bull_cup ? e); #bc;
683 nchange in match (𝐋\p (•e)) in bc with (?∪?);
684 nchange in match b' in bc with b';
685 ncases b' in bc; ##[##2: nrewrite > (cup0…); nrewrite > (sub0…); //]
686 nrewrite > (cup_sub…); ##[napply rcanc_sing] //;##]
687 nrewrite > (cup_dotD…); nrewrite > (cupA…);nrewrite > (erase_bull…);
688 nrewrite > (sub_dot_star…);
689 nchange in match (𝐋\p 〈?,?〉) with (?∪?);
690 nrewrite > (cup_dotD…); nrewrite > (epsilon_dot…); //;
691 ##| nwhd in match (〈e,false〉^⊛); nchange in match (𝐋\p 〈?,?〉) with (?∪?);
693 nchange in ⊢ (??%?) with (𝐋\p e · 𝐋 .|e|^* );
694 nrewrite < (cup0 ? (𝐋\p e)); //;##]
697 nlet rec pre_of_re (S : Alpha) (e : re S) on e : pitem S ≝
702 | c e1 e2 ⇒ pc ? (pre_of_re ? e1) (pre_of_re ? e2)
703 | o e1 e2 ⇒ po ? (pre_of_re ? e1) (pre_of_re ? e2)
704 | k e1 ⇒ pk ? (pre_of_re ? e1)].
706 nlemma notFalse : ¬False. @; //; nqed.
708 nlemma dot0 : ∀S.∀A:word S → Prop. {} · A = {}.
709 #S A; nnormalize; napply extP; #w; @; ##[##2: *]
710 *; #w1; *; #w2; *; *; //; nqed.
712 nlemma Lp_pre_of_re : ∀S.∀e:re S. 𝐋\p (pre_of_re ? e) = {}.
713 #S e; nelim e; ##[##1,2,3: //]
714 ##[ #e1 e2 H1 H2; nchange in match (𝐋\p (pre_of_re S (e1 e2))) with (?∪?);
715 nrewrite > H1; nrewrite > H2; nrewrite > (dot0…); nrewrite > (cupID…);//
716 ##| #e1 e2 H1 H2; nchange in match (𝐋\p (pre_of_re S (e1+e2))) with (?∪?);
717 nrewrite > H1; nrewrite > H2; nrewrite > (cupID…); //
718 ##| #e1 H1; nchange in match (𝐋\p (pre_of_re S (e1^* ))) with (𝐋\p (pre_of_re ??) · ?);
719 nrewrite > H1; napply dot0; ##]
722 nlemma erase_pre_of_reK : ∀S.∀e. 𝐋 .|pre_of_re S e| = 𝐋 e.
724 ##[ #e1 e2 H1 H2; nchange in match (𝐋 (e1 · e2)) with (𝐋 e1·?);
725 nrewrite < H1; nrewrite < H2; //
726 ##| #e1 e2 H1 H2; nchange in match (𝐋 (e1 + e2)) with (𝐋 e1 ∪ ?);
727 nrewrite < H1; nrewrite < H2; //
728 ##| #e1 H1; nchange in match (𝐋 (e1^* )) with ((𝐋 e1)^* );
733 nlemma L_Lp_bull : ∀S.∀e:re S.𝐋 e = 𝐋\p (•pre_of_re ? e).
734 #S e; nrewrite > (bull_cup…); nrewrite > (Lp_pre_of_re…);
735 nrewrite > (cupC…); nrewrite > (cup0…); nrewrite > (erase_pre_of_reK…); //;
738 nlemma Pext : ∀S.∀f,g:word S → Prop. f = g → ∀w.f w → g w.
739 #S f g H; nrewrite > H; //; nqed.
742 ntheorem bull_true_epsilon : ∀S.∀e:pitem S. \snd (•e) = true ↔ [ ] ∈ .|e|.
744 ##[ #defsnde; nlapply (bull_cup ? e); nchange in match (𝐋\p (•e)) with (?∪?);
745 nrewrite > defsnde; #H;
746 nlapply (Pext ??? H [ ] ?); ##[ @2; //] *; //;
751 notation > "\move term 90 x term 90 E"
752 non associative with precedence 60 for @{move ? $x $E}.
753 nlet rec move (S: Alpha) (x:S) (E: pitem S) on E : pre S ≝
757 | ps y ⇒ 〈 `y, false 〉
758 | pp y ⇒ 〈 `y, x == y 〉
759 | po e1 e2 ⇒ \move x e1 ⊕ \move x e2
760 | pc e1 e2 ⇒ \move x e1 ⊙ \move x e2
761 | pk e ⇒ (\move x e)^⊛ ].
762 notation < "\move\shy x\shy E" non associative with precedence 60 for @{'move $x $E}.
763 notation > "\move term 90 x term 90 E" non associative with precedence 60 for @{'move $x $E}.
764 interpretation "move" 'move x E = (move ? x E).
766 ndefinition rmove ≝ λS:Alpha.λx:S.λe:pre S. \move x (\fst e).
767 interpretation "rmove" 'move x E = (rmove ? x E).
769 nlemma XXz : ∀S:Alpha.∀w:word S. w .∈ ∅ → False.
770 #S w abs; ninversion abs; #; ndestruct;
774 nlemma XXe : ∀S:Alpha.∀w:word S. w .∈ ϵ → False.
775 #S w abs; ninversion abs; #; ndestruct;
778 nlemma XXze : ∀S:Alpha.∀w:word S. w .∈ (∅ · ϵ) → False.
779 #S w abs; ninversion abs; #; ndestruct; /2/ by XXz,XXe;
784 ∀S.∀w:word S.∀x.∀E1,E2:pitem S. w .∈ \move x (E1 · E2) →
785 (∃w1.∃w2. w = w1@w2 ∧ w1 .∈ \move x E1 ∧ w2 ∈ .|E2|) ∨ w .∈ \move x E2.
786 #S w x e1 e2 H; nchange in H with (w .∈ \move x e1 ⊙ \move x e2);
787 ncases e1 in H; ncases e2;
788 ##[##1: *; ##[*; nnormalize; #; ndestruct]
789 #H; ninversion H; ##[##1,4,5,6: nnormalize; #; ndestruct]
790 nnormalize; #; ndestruct; ncases (?:False); /2/ by XXz,XXze;
791 ##|##2: *; ##[*; nnormalize; #; ndestruct]
792 #H; ninversion H; ##[##1,4,5,6: nnormalize; #; ndestruct]
793 nnormalize; #; ndestruct; ncases (?:False); /2/ by XXz,XXze;
794 ##| #r; *; ##[ *; nnormalize; #; ndestruct]
795 #H; ninversion H; ##[##1,4,5,6: nnormalize; #; ndestruct]
796 ##[##2: nnormalize; #; ndestruct; @2; @2; //.##]
797 nnormalize; #; ndestruct; ncases (?:False); /2/ by XXz;
798 ##| #y; *; ##[ *; nnormalize; #defw defx; ndestruct; @2; @1; /2/ by conj;##]
799 #H; ninversion H; nnormalize; #; ndestruct;
800 ##[ncases (?:False); /2/ by XXz] /3/ by or_intror;
801 ##| #r1 r2; *; ##[ *; #defw]
806 ∀S:Alpha.∀E:pre S.∀a,w.w .∈ \move a E ↔ (a :: w) .∈ E.
807 #S E; ncases E; #r b; nelim r;
809 ##[##1,3: nnormalize; *; ##[##1,3: *; #; ndestruct; ##| #abs; ncases (XXz … abs); ##]
810 #H; ninversion H; #; ndestruct;
811 ##|##*:nnormalize; *; ##[##1,3: *; #; ndestruct; ##| #H1; ncases (XXz … H1); ##]
812 #H; ninversion H; #; ndestruct;##]
813 ##|#a c w; @; nnormalize; ##[*; ##[*; #; ndestruct; ##] #abs; ninversion abs; #; ndestruct;##]
814 *; ##[##2: #abs; ninversion abs; #; ndestruct; ##] *; #; ndestruct;
815 ##|#a c w; @; nnormalize;
816 ##[ *; ##[ *; #defw; nrewrite > defw; #ca; @2; nrewrite > (eqb_t … ca); @; ##]
817 #H; ninversion H; #; ndestruct;
818 ##| *; ##[ *; #; ndestruct; ##] #H; ninversion H; ##[##2,3,4,5,6: #; ndestruct]
819 #d defw defa; ndestruct; @1; @; //; nrewrite > (eqb_true S d d); //. ##]
820 ##|#r1 r2 H1 H2 a w; @;
821 ##[ #H; ncases (in_move_cat … H);
822 ##[ *; #w1; *; #w2; *; *; #defw w1m w2m;
823 ncases (H1 a w1); #H1w1; #_; nlapply (H1w1 w1m); #good;
824 nrewrite > defw; @2; @2 (a::w1); //; ncases good; ##[ *; #; ndestruct] //.
833 notation > "x ↦* E" non associative with precedence 60 for @{move_star ? $x $E}.
834 nlet rec move_star (S : decidable) w E on w : bool × (pre S) ≝
837 | cons x w' ⇒ w' ↦* (x ↦ \snd E)].
839 ndefinition in_moves ≝ λS:decidable.λw.λE:bool × (pre S). \fst(w ↦* E).
841 ncoinductive equiv (S:decidable) : bool × (pre S) → bool × (pre S) → Prop ≝
843 ∀E1,E2: bool × (pre S).
845 (∀x. equiv S (x ↦ \snd E1) (x ↦ \snd E2)) →
848 ndefinition NAT: decidable.
852 include "hints_declaration.ma".
854 alias symbol "hint_decl" (instance 1) = "hint_decl_Type1".
855 unification hint 0 ≔ ; X ≟ NAT ⊢ carr X ≡ nat.
857 ninductive unit: Type[0] ≝ I: unit.
859 nlet corec foo_nop (b: bool):
861 〈 b, pc ? (ps ? 0) (pk ? (pc ? (ps ? 1) (ps ? 0))) 〉
862 〈 b, pc ? (pk ? (pc ? (ps ? 0) (ps ? 1))) (ps ? 0) 〉 ≝ ?.
864 [ nnormalize in ⊢ (??%%); napply (foo_nop false)
866 [ nnormalize in ⊢ (??%%); napply (foo_nop false)
867 | #w; nnormalize in ⊢ (??%%); napply (foo_nop false) ]##]
871 nlet corec foo (a: unit):
873 (eclose NAT (pc ? (ps ? 0) (pk ? (pc ? (ps ? 1) (ps ? 0)))))
874 (eclose NAT (pc ? (pk ? (pc ? (ps ? 0) (ps ? 1))) (ps ? 0)))
879 [ nnormalize in ⊢ (??%%);
880 nnormalize in foo: (? → ??%%);
882 [ nnormalize in ⊢ (??%%); napply foo_nop
884 [ nnormalize in ⊢ (??%%);
886 ##| #z; nnormalize in ⊢ (??%%); napply foo_nop ]##]
887 ##| #y; nnormalize in ⊢ (??%%); napply foo_nop
892 ndefinition test1 : pre ? ≝ ❨ `0 | `1 ❩^* `0.
893 ndefinition test2 : pre ? ≝ ❨ (`0`1)^* `0 | (`0`1)^* `1 ❩.
894 ndefinition test3 : pre ? ≝ (`0 (`0`1)^* `1)^*.
897 nlemma foo: in_moves ? [0;0;1;0;1;1] (ɛ test3) = true.
898 nnormalize in match test3;
903 (**********************************************************)
905 ninductive der (S: Type[0]) (a: S) : re S → re S → CProp[0] ≝
906 der_z: der S a (z S) (z S)
907 | der_e: der S a (e S) (z S)
908 | der_s1: der S a (s S a) (e ?)
909 | der_s2: ∀b. a ≠ b → der S a (s S b) (z S)
910 | der_c1: ∀e1,e2,e1',e2'. in_l S [] e1 → der S a e1 e1' → der S a e2 e2' →
911 der S a (c ? e1 e2) (o ? (c ? e1' e2) e2')
912 | der_c2: ∀e1,e2,e1'. Not (in_l S [] e1) → der S a e1 e1' →
913 der S a (c ? e1 e2) (c ? e1' e2)
914 | der_o: ∀e1,e2,e1',e2'. der S a e1 e1' → der S a e2 e2' →
915 der S a (o ? e1 e2) (o ? e1' e2').
917 nlemma eq_rect_CProp0_r:
918 ∀A.∀a,x.∀p:eq ? x a.∀P: ∀x:A. eq ? x a → CProp[0]. P a (refl A a) → P x p.
919 #A; #a; #x; #p; ncases p; #P; #H; nassumption.
922 nlemma append1: ∀A.∀a:A.∀l. [a] @ l = a::l. //. nqed.
924 naxiom in_l1: ∀S,r1,r2,w. in_l S [ ] r1 → in_l S w r2 → in_l S w (c S r1 r2).
925 (* #S; #r1; #r2; #w; nelim r1
927 | #H1; #H2; napply (in_c ? []); //
928 | (* tutti casi assurdi *) *)
930 ninductive in_l' (S: Type[0]) : word S → re S → CProp[0] ≝
931 in_l_empty1: ∀E.in_l S [] E → in_l' S [] E
932 | in_l_cons: ∀a,w,e,e'. in_l' S w e' → der S a e e' → in_l' S (a::w) e.
934 ncoinductive eq_re (S: Type[0]) : re S → re S → CProp[0] ≝
936 (in_l S [] E1 → in_l S [] E2) →
937 (in_l S [] E2 → in_l S [] E1) →
938 (∀a,E1',E2'. der S a E1 E1' → der S a E2 E2' → eq_re S E1' E2') →
941 (* serve il lemma dopo? *)
942 ntheorem eq_re_is_eq: ∀S.∀E1,E2. eq_re S E1 E2 → ∀w. in_l ? w E1 → in_l ? w E2.
943 #S; #E1; #E2; #H1; #w; #H2; nelim H2 in E2 H1 ⊢ %
945 | #a; #w; #R1; #R2; #K1; #K2; #K3; #R3; #K4; @2 R2; //; ncases K4;
947 (* IL VICEVERSA NON VALE *)
948 naxiom in_l_to_in_l: ∀S,w,E. in_l' S w E → in_l S w E.
949 (* #S; #w; #E; #H; nelim H
951 | #a; #w'; #r; #r'; #H1; (* e si cade qua sotto! *)
955 ntheorem der1: ∀S,a,e,e',w. der S a e e' → in_l S w e' → in_l S (a::w) e.
956 #S; #a; #E; #E'; #w; #H; nelim H
957 [##1,2: #H1; ninversion H1
958 [##1,8: #_; #K; (* non va ndestruct K; *) ncases (?:False); (* perche' due goal?*) /2/
959 |##2,9: #X; #Y; #K; ncases (?:False); /2/
960 |##3,10: #x; #y; #z; #w; #a; #b; #c; #d; #e; #K; ncases (?:False); /2/
961 |##4,11: #x; #y; #z; #w; #a; #b; #K; ncases (?:False); /2/
962 |##5,12: #x; #y; #z; #w; #a; #b; #K; ncases (?:False); /2/
963 |##6,13: #x; #y; #K; ncases (?:False); /2/
964 |##7,14: #x; #y; #z; #w; #a; #b; #c; #d; #K; ncases (?:False); /2/]
965 ##| #H1; ninversion H1
967 | #X; #Y; #K; ncases (?:False); /2/
968 | #x; #y; #z; #w; #a; #b; #c; #d; #e; #K; ncases (?:False); /2/
969 | #x; #y; #z; #w; #a; #b; #K; ncases (?:False); /2/
970 | #x; #y; #z; #w; #a; #b; #K; ncases (?:False); /2/
971 | #x; #y; #K; ncases (?:False); /2/
972 | #x; #y; #z; #w; #a; #b; #c; #d; #K; ncases (?:False); /2/ ]
973 ##| #H1; #H2; #H3; ninversion H3
974 [ #_; #K; ncases (?:False); /2/
975 | #X; #Y; #K; ncases (?:False); /2/
976 | #x; #y; #z; #w; #a; #b; #c; #d; #e; #K; ncases (?:False); /2/
977 | #x; #y; #z; #w; #a; #b; #K; ncases (?:False); /2/
978 | #x; #y; #z; #w; #a; #b; #K; ncases (?:False); /2/
979 | #x; #y; #K; ncases (?:False); /2/
980 | #x; #y; #z; #w; #a; #b; #c; #d; #K; ncases (?:False); /2/ ]
981 ##| #r1; #r2; #r1'; #r2'; #H1; #H2; #H3; #H4; #H5; #H6;