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 (**************************************************************************)
18 * beta reduction relation
19 * EASY TO SEE THAT BETA IS EQUIVARIANT, IMPLIES WELL-FORMEDNESS AND
20 * DOES NOT CREATE NEW FREE GLOBAL VARIABLES
22 inductive beta (F: X → S_exp → Y) : S_exp → S_exp → Prop ≝
23 | b_redex : ∀y,M,N.L F (Abs y M) → L F N →
24 beta F (App (Abs y M) N) (subst_Y M y N)
25 | b_app1 : ∀M1,M2,N.beta F M1 M2 → L F N → beta F (App M1 N) (App M2 N)
26 | b_app2 : ∀M,N1,N2.L F M → beta F N1 N2 → beta F (App M N1) (App M N2)
27 | b_xi : ∀M,N,x.beta F M N → beta F (Abs (F x M) (subst_X M x (Var (F x M))))
28 (Abs (F x N) (subst_X N x (Var (F x N)))).
30 (* parallel reduction relation, should have the same properties *)
31 inductive pr (F: X → S_exp → Y) : S_exp → S_exp → Prop ≝
32 | pr_par : ∀x.pr F (Par x) (Par x)
33 | pr_redex : ∀x,M1,M2,N1,N2.pr F M1 M2 → pr F N1 N2 →
34 pr F (App (Abs (F x M1) (subst_X M1 x (Var (F x M1)))) N1)
36 | pr_app : ∀M1,M2,N1,N2.pr F M1 M2 → pr F N1 N2 → pr F (App M1 N1) (App M2 N2)
37 | pr_xi : ∀M,N,x.pr F M N → pr F (Abs (F x M) (subst_X M x (Var (F x M))))
38 (Abs (F x N) (subst_X N x (Var (F x N)))).
40 (* complete development relation, should have the same properties *)
41 inductive cd (F: X → S_exp → Y) : S_exp → S_exp → Prop ≝
42 | cd_par : ∀x.cd F (Par x) (Par x)
43 | cd_redex : ∀x,M1,M2,N1,N2.cd F M1 M2 → cd F N1 N2 →
44 cd F (App (Abs (F x M1) (subst_X M1 x (Var (F x M1)))) N1)
46 | cd_app : ∀M1,M2,N1,N2.(∀y,P.M1 ≠ Abs y P) →
47 cd F M1 M2 → cd F N1 N2 → cd F (App M1 N1) (App M2 N2)
48 | cd_xi : ∀M,N,x.cd F M N → cd F (Abs (F x M) (subst_X M x (Var (F x M))))
49 (Abs (F x N) (subst_X N x (Var (F x N)))).
51 notation < "hvbox(a break maction (>) (> \sub f) b)"
52 non associative with precedence 45
53 for @{ 'gt $f $a $b }.
54 notation < "hvbox(a break maction (≫) (≫\sub f) b)"
55 non associative with precedence 45
56 for @{ 'ggt $f $a $b }.
57 notation < "hvbox(a break maction (⋙) (⋙\sub f) b)"
58 non associative with precedence 45
59 for @{ 'gggt $f $a $b }.
61 notation > "hvbox(a break >[f] b)"
62 non associative with precedence 45
63 for @{ 'gt $f $a $b }.
64 notation > "hvbox(a break ≫[f] b)"
65 non associative with precedence 45
66 for @{ 'ggt $f $a $b }.
67 notation > "hvbox(a break ⋙[f] b)"
68 non associative with precedence 45
69 for @{ 'gggt $f $a $b }.
71 interpretation "pollack-sato beta reduction" 'gt F M N = (beta F M N).
72 interpretation "pollack-sato parallel reduction" 'ggt F M N = (pr F M N).
73 interpretation "pollack-sato complete development" 'gggt F M N = (cd F M N).
75 lemma cd_exists : ∀F:xheight.∀M.L F M → ∃N.M ⋙[F] N.
78 |generalize in match H2;generalize in match H1;clear H1 H2;cases s;intros
79 [1,2,3:cases H2;cases H4;exists [1,3,5:apply (App x x1)]
81 [1,4,7:intros;intro;destruct
83 |inversion H1;simplify;intros;destruct;clear H5 H6;
84 cases H2;clear H2;inversion H5;simplify;intros;destruct;
85 cases H4;clear H4 H6;exists
91 |cases H2;clear H2;exists
96 axiom pi_swap_inv : ∀u,v,M.pi_swap ? u v · (pi_swap ? u v · M) = M.
99 lemma pr_swap : ∀F:xheight.∀M,N,x1,x2.
100 M ≫[F] N → pi_swap ? x1 x2 · M ≫[F] pi_swap ? x1 x2 · N.
103 |simplify;do 2 rewrite > pi_lemma1;simplify;
104 rewrite > (? : F c s = F (pi_swap ? x1 x2 c) (pi_swap ? x1 x2 · s));
107 |simplify;do 2 rewrite > pi_lemma1;simplify;
108 rewrite > (? : F c s = F (pi_swap ? x1 x2 c) (pi_swap ? x1 x2 · s));
109 [rewrite > (? : F c s1 = F (pi_swap ? x1 x2 c) (pi_swap ? x1 x2 · s1));
114 inductive pr2 (F: X → S_exp → Y) : S_exp → S_exp → Prop ≝
115 | pr2_par : ∀x.pr2 F (Par x) (Par x)
116 | pr2_redex : ∀x1,M1,M2,N1,N2.
117 (∀x2.(x2 ∈ GV M1 → x2 = x1) →
118 pr2 F (subst_X M1 x1 (Par x2)) (subst_X M2 x1 (Par x2))) →
120 pr2 F (App (Abs (F x1 M1) (subst_X M1 x1 (Var (F x1 M1)))) N1)
122 | pr2_app : ∀M1,M2,N1,N2.pr2 F M1 M2 → pr2 F N1 N2 → pr2 F (App M1 N1) (App M2 N2)
124 (∀x2.(x2 ∈ GV M → x2 = x1) →
125 pr2 F (subst_X M x1 (Par x2)) (subst_X N x1 (Par x2))) →
126 pr2 F (Abs (F x1 M) (subst_X M x1 (Var (F x1 M))))
127 (Abs (F x1 N) (subst_X N x1 (Var (F x1 N)))).
129 inductive np (F: X → S_exp → Y) : S_exp → S_exp → Prop ≝
130 | k1 : ∀x,M1,M2,N1,N2.np F M1 M2 → np F N1 N2 →
131 np F (App (Abs (F x M1) (subst_X M1 x (Var (F x M1)))) N1)
134 (*lemma np_strong_swap : ∀F:X→S_exp→Y.∀P:S_exp→S_exp→Prop.
140 (∀x.(x ∈ GV s → x = c) →
141 P (subst_X s c (Par x)) (subst_X s1 c (Par x))) →
143 P (App (Abs (F c s) (subst_X s c (Var (F c s)))) s2) (subst_X s1 c s3)) →
144 ∀s:S_exp.∀s1:S_exp.np F s s1→∀f:finite_perm X.P (f · s) (f · s1).
145 intros 6;elim H1;simplify;
146 rewrite > (?: f ·subst_X s3 c s5 = subst_X (f · s3) (f c) (f · s5))
147 [rewrite > (?: f ·subst_X s2 c (Var (F c s2)) = subst_X (f · s2) (f c) (Var (F c s2)))
148 [rewrite > (? : F c s2 = F (f c) (f · s2))
150 [intros;rewrite > subst_X_fp [|assumption]
151 rewrite > subst_X_fp [|elim daemon]
158 lemma pr2_swap : ∀F:xheight.∀M,N,x1,x2.
159 pr2 F M N → pr2 F (pi_swap ? x1 x2 · M) (pi_swap ? x1 x2 · N).
162 |simplify;do 2 rewrite > pi_lemma1;simplify;
163 rewrite > (? : F c s = F (pi_swap ? x1 x2 c) (pi_swap ? x1 x2 · s))
165 [intros;lapply (H2 (pi_swap ? x1 x2 x))
166 [rewrite > (? : Par x = pi_swap X x1 x2 · (Par (pi_swap X x1 x2 x)));
168 |intro;rewrite < (swap_inv ? x1 x2 c);rewrite < eq_swap_pi;
170 rewrite < (swap_inv ? x1 x2 x);autobatch]
174 |simplify;do 2 rewrite > pi_lemma1;simplify;
175 rewrite > (? : F c s = F (pi_swap ? x1 x2 c) (pi_swap ? x1 x2 · s));
176 [rewrite > (? : F c s1 = F (pi_swap ? x1 x2 c) (pi_swap ? x1 x2 · s1));
177 [apply pr2_xi;intros;lapply (H2 (pi_swap ? x1 x2 x))
178 [rewrite > (? : Par x = pi_swap X x1 x2 · (Par (pi_swap X x1 x2 x)));
180 |intro;rewrite < (swap_inv ? x1 x2 c);rewrite < eq_swap_pi;
182 rewrite < (swap_inv ? x1 x2 x);autobatch]
187 (* TODO : a couple of clear but not trivial open subproofs *)
188 lemma pr_GV_incl : ∀F:xheight.∀M,N.M ≫[F] N → GV N ⊆ GV M.
189 intros;elim H;simplify
191 |cut (GV (subst_X s1 c s3) ⊆ filter ? (GV s1) (λz.¬ (c ≟ z)) @ GV s3)
192 [unfold;intros;cases (in_list_append_to_or_in_list ???? (Hcut ? H5))
193 [apply in_list_to_in_list_append_l;
194 cases (GV_subst_X_Var s c (F c s) x);clear H7;apply H8;
195 (* reasoning from H2 and monotonicity of filter *)
198 |(* boring *) elim daemon]
199 |unfold;intros;cases (in_list_append_to_or_in_list ???? H5);autobatch
200 |unfold;intros;cases (GV_subst_X_Var s c (F c s) x);
202 cases (GV_subst_X_Var s1 c (F c s1) x);lapply (H4 H3);clear H4 H6;
203 (* Hletin and monotonicity of filter *)
207 lemma pr_to_pr2 : ∀F:xheight.∀M,N.M ≫[F] N → pr2 F M N.
211 [intros;rewrite > subst_X_fp
212 [rewrite > subst_X_fp
214 |intro;apply H5;apply pr_GV_incl;
220 |apply pr2_xi;intros;rewrite > subst_X_fp
221 [rewrite > subst_X_fp
223 |intro;apply H3;apply pr_GV_incl
229 lemma pr2_to_pr : ∀F:xheight.∀M,N.pr2 F M N → M ≫[F] N.
233 [applyS (H2 c);intro;reflexivity
235 |apply pr_xi;applyS (H2 c);intro;reflexivity]
238 (* ugly, must factorize *)
239 lemma pr_subst_X : ∀F:xheight.∀M1,M2,x,N1,N2.
240 M1 ≫[F] M2 → N1 ≫[F] N2 →
241 subst_X M1 x N1 ≫[F] subst_X M2 x N2.
242 intros;lapply (pr_to_pr2 ??? H) as H';clear H;
243 generalize in match H1;generalize in match N2 as N2;generalize in match N1 as N1;
246 [simplify;apply (bool_elim ? (x ≟ c));simplify;intro;autobatch
247 |generalize in match (p_fresh ? (x::GV s @GV N1));
248 generalize in match (N_fresh ??);
250 rewrite > (?: Abs (F c s) (subst_X s c (Var (F c s))) =
251 Abs (F c1 (pi_swap ? c c1 · s))
252 (subst_X (pi_swap ? c c1 · s) c1 (Var (F c1 (pi_swap ? c c1 · s)))))
253 [rewrite > (?: subst_X s1 c s3 = subst_X (pi_swap ? c c1 · s1) c1 s3)
254 [simplify;rewrite > subst_X_lemma
255 [rewrite > subst_X_lemma in ⊢ (???%)
256 [rewrite > (?: F c1 (pi_swap ? c c1 · s) =
257 F c1 (subst_X (pi_swap ? c c1 · s) x N1))
258 [simplify in ⊢ (? ? (? (? ? (? ? ? %)) ?) ?);apply pr_redex
259 [rewrite < subst_X_fp
260 [rewrite < subst_X_fp
262 [intro Hfalse;elim Hc1;autobatch
264 |intro Hfalse;elim Hc1;
265 apply in_list_cons;apply in_list_to_in_list_append_l;
266 lapply (H c) [|intro;reflexivity]
267 lapply (pr2_to_pr ??? Hletin);
268 do 2 rewrite > subst_X_x_x in Hletin1;
269 apply (pr_GV_incl ??? Hletin1);assumption]
270 |intro Hfalse;elim Hc1;autobatch]
272 |apply p_eqb1;apply XHP
273 [apply p_eqb4;intro Hfalse;apply Hc1;rewrite > Hfalse;autobatch
274 |apply apart_to_apartb_true;unfold;autobatch]]
275 |*:intro Hfalse;autobatch]
276 |*:intro Hfalse;autobatch]
277 |rewrite < subst_X_fp
278 [rewrite > subst_X_merge
280 |intro Hfalse;autobatch]
281 |intro Hfalse;elim Hc1;
282 apply in_list_cons;apply in_list_to_in_list_append_l;
283 lapply (H c) [|intro;reflexivity]
284 do 2 rewrite > subst_X_x_x in Hletin;
285 lapply (pr2_to_pr ??? Hletin);autobatch]]
286 |rewrite < (swap_left ? c c1) in ⊢ (? ? ? (? (??%?) (? ? % (? (? ? % ?)))));
287 rewrite > eq_swap_pi;rewrite < XHE;
288 change in ⊢ (???(??(???%))) with (pi_swap ? c c1 · (Var (F c s)));
289 rewrite < pi_lemma1;rewrite < subst_X_fp
290 [rewrite > (subst_X_apart ?? (Par c1))
292 |elim daemon (* don't we have a lemma? *)]
293 |intro Hfalse;elim Hc1;
294 apply in_list_cons;apply in_list_to_in_list_append_l;(* lemma?? *) elim daemon]]
296 |generalize in match (p_fresh ? (x::GV s @GV N1));
297 generalize in match (N_fresh ??);
299 rewrite > (?: Abs (F c s) (subst_X s c (Var (F c s))) =
300 Abs (F c1 (pi_swap ? c c1 · s))
301 (subst_X (pi_swap ? c c1 · s) c1 (Var (F c1 (pi_swap ? c c1 · s)))));
302 [rewrite > (?: Abs (F c s1) (subst_X s1 c (Var (F c s1))) =
303 Abs (F c1 (pi_swap ? c c1 · s1))
304 (subst_X (pi_swap ? c c1 · s1) c1 (Var (F c1 (pi_swap ? c c1 · s1)))));
305 [simplify;rewrite > subst_X_lemma
306 [rewrite > subst_X_lemma in ⊢ (???%)
307 [simplify;rewrite > (? : F c1 (pi_swap ? c c1 · s) = F c1 (subst_X (pi_swap ? c c1 · s) x N1))
308 [rewrite > (? : F c1 (pi_swap ? c c1 · s1) = F c1 (subst_X (pi_swap ? c c1 · s1) x N2))
309 [apply pr_xi;rewrite < subst_X_fp
310 [rewrite < subst_X_fp
312 [intro Hfalse;elim Hc1;autobatch
314 |intro Hfalse; (* meglio fare qualcosa di più furbo *) elim daemon]
315 |intro;elim Hc1;autobatch]
316 |apply p_eqb1;apply XHP
317 [apply p_eqb4;intro Hfalse;autobatch
318 |apply apart_to_apartb_true;intro;autobatch]]
319 |apply p_eqb1;apply XHP
320 [apply p_eqb4;intro Hfalse;autobatch
321 |apply apart_to_apartb_true;intro;autobatch]]
322 |*:intro;apply Hc1;autobatch]
323 |*:intro;apply Hc1;autobatch]
326 |rewrite < (swap_left ? c c1) in ⊢ (??? (??% (? (??%?))));
327 rewrite > eq_swap_pi;rewrite < XHE;
328 change in ⊢ (???(???%)) with (pi_swap ? c c1 · (Var (F c s1)));
329 rewrite < pi_lemma1;rewrite < subst_X_fp
330 [rewrite > (subst_X_apart ?? (Par c1))
332 |elim daemon (* don't we have a lemma? *)]
333 |intro Hfalse;elim Hc1;
334 apply in_list_cons;apply in_list_to_in_list_append_l;(* lemma?? *) elim daemon]]]
337 |rewrite < (swap_left ? c c1) in ⊢ (??? (??% (? (??%?))));
338 rewrite > eq_swap_pi;rewrite < XHE;
339 change in ⊢ (???(???%)) with (pi_swap ? c c1 · (Var (F c s)));
340 rewrite < pi_lemma1;rewrite < subst_X_fp
341 [rewrite > (subst_X_apart ?? (Par c1))
343 |elim daemon (* don't we have a lemma? *)]
344 |intro Hfalse;elim Hc1;
345 apply in_list_cons;apply in_list_to_in_list_append_l;(* lemma?? *) elim daemon]]]]
348 lemma L_subst_X : ∀F:xheight.∀M,x,N.L F M → L F N → L F (subst_X M x N).
349 intros;elim (L_to_LL ?? H);
350 [simplify;cases (x ≟ c);simplify;autobatch
352 |generalize in match (p_fresh ? (x::GV s @GV N));
353 generalize in match (N_fresh ??);
355 rewrite > (?: Abs (F c s) (subst_X s c (Var (F c s))) =
356 Abs (F c1 (pi_swap ? c c1 · s))
357 (subst_X (pi_swap ? c c1 · s) c1 (Var (F c1 (pi_swap ? c c1 · s)))));
358 [simplify;rewrite > subst_X_lemma
359 [simplify;rewrite > (? : F c1 (pi_swap ? c c1 · s) = F c1 (subst_X (pi_swap ? c c1 · s) x N))
360 [apply LAbs;rewrite < subst_X_fp
361 [apply H3;intro Hfalse;elim Hc1;autobatch
362 |intro Hfalse;elim Hc1;autobatch]
363 |apply p_eqb1;apply XHP
364 [apply p_eqb4;intro Hfalse;autobatch
365 |apply apart_to_apartb_true;intro;autobatch]]
366 |*:intro;apply Hc1;autobatch]
369 |rewrite < (swap_left ? c c1) in ⊢ (??? (??% (? (??%?))));
370 rewrite > eq_swap_pi;rewrite < XHE;
371 change in ⊢ (???(???%)) with (pi_swap ? c c1 · (Var (F c s)));
372 rewrite < pi_lemma1;rewrite < subst_X_fp
373 [rewrite > (subst_X_apart ?? (Par c1))
375 |elim daemon (* don't we have a lemma? *)]
376 |intro Hfalse;elim Hc1;
377 apply in_list_cons;apply in_list_to_in_list_append_l;
378 (* lemma?? *) elim daemon]]]]
381 inductive cd2 (F: X → S_exp → Y) : S_exp → S_exp → Prop ≝
382 | cd2_par : ∀x.cd2 F (Par x) (Par x)
383 | cd2_redex : ∀x,M1,M2,N1,N2.
384 (∀x2.(x2 ∈ GV M1 → x2 = x) →
385 cd2 F (subst_X M1 x (Par x2)) (subst_X M2 x (Par x2))) →
387 cd2 F (App (Abs (F x M1) (subst_X M1 x (Var (F x M1)))) N1)
389 | cd2_app : ∀M1,M2,N1,N2.(∀y,P.M1 ≠ Abs y P) →
390 cd2 F M1 M2 → cd2 F N1 N2 → cd2 F (App M1 N1) (App M2 N2)
391 | cd2_xi : ∀M,N,x.(∀x2.(x2 ∈ GV M → x2 = x) →
392 cd2 F (subst_X M x (Par x2)) (subst_X N x (Par x2))) →
393 cd2 F (Abs (F x M) (subst_X M x (Var (F x M))))
394 (Abs (F x N) (subst_X N x (Var (F x N)))).
396 lemma cd2_swap : ∀F:xheight.∀M,N,x1,x2.
397 cd2 F M N → cd2 F (pi_swap ? x1 x2 · M) (pi_swap ? x1 x2 · N).
400 |simplify;do 2 rewrite > pi_lemma1;simplify;
401 rewrite > (? : F c s = F (pi_swap ? x1 x2 c) (pi_swap ? x1 x2 · s))
403 [intros;lapply (H2 (pi_swap ? x1 x2 x))
404 [rewrite > (? : Par x = pi_swap X x1 x2 · (Par (pi_swap X x1 x2 x)));
406 |intro;rewrite < (swap_inv ? x1 x2 c);rewrite < eq_swap_pi;
408 rewrite < (swap_inv ? x1 x2 x);autobatch]
411 |simplify;apply cd2_app;
412 [intros;generalize in match H1;cases s;simplify;intros 2;destruct;
413 elim H6;[3:reflexivity|*:skip]
415 |simplify;do 2 rewrite > pi_lemma1;simplify;
416 rewrite > (? : F c s = F (pi_swap ? x1 x2 c) (pi_swap ? x1 x2 · s));
417 [rewrite > (? : F c s1 = F (pi_swap ? x1 x2 c) (pi_swap ? x1 x2 · s1));
418 [apply cd2_xi;intros;lapply (H2 (pi_swap ? x1 x2 x))
419 [rewrite > (? : Par x = pi_swap X x1 x2 · (Par (pi_swap X x1 x2 x)));
421 |intro;rewrite < (swap_inv ? x1 x2 c);rewrite < eq_swap_pi;
423 rewrite < (swap_inv ? x1 x2 x);autobatch]
428 lemma cd_GV_incl : ∀F:xheight.∀M,N.M ⋙[F] N → GV N ⊆ GV M.
429 intros;elim H;simplify
431 |cut (GV (subst_X s1 c s3) ⊆ filter ? (GV s1) (λz.¬ (c ≟ z)) @ GV s3)
432 [unfold;intros;cases (in_list_append_to_or_in_list ???? (Hcut ? H5))
433 [apply in_list_to_in_list_append_l;
434 cases (GV_subst_X_Var s c (F c s) x);clear H7;apply H8;
435 (* reasoning from H2 and monotonicity of filter *)
438 |(* boring *) elim daemon]
439 |unfold;intros;cases (in_list_append_to_or_in_list ???? H6);autobatch
440 |unfold;intros;cases (GV_subst_X_Var s c (F c s) x);
442 cases (GV_subst_X_Var s1 c (F c s1) x);lapply (H4 H3);clear H4 H6;
443 (* Hletin and monotonicity of filter *)
447 lemma cd_to_cd2 : ∀F:xheight.∀M,N.M ⋙[F] N → cd2 F M N.
451 [intros;rewrite > subst_X_fp
452 [rewrite > subst_X_fp
454 |intro;apply H5;apply cd_GV_incl;
460 |apply cd2_xi;intros;rewrite > subst_X_fp
461 [rewrite > subst_X_fp
463 |intro;apply H3;apply cd_GV_incl
469 lemma pr_cd_triangle : ∀F:xheight.∀M,N,P.M ≫[F] N → M ⋙[F] P → N ≫[F] P.
470 intros;generalize in match H;generalize in match N;clear H N;
471 elim (cd_to_cd2 ??? H1)
472 [inversion H;simplify;intros;destruct;autobatch
473 |inversion (pr_to_pr2 ??? H5);simplify;intros;destruct;
475 lapply (H4 ? (pr2_to_pr ??? H8)) as H9;clear H4;
476 generalize in match (p_fresh ? (GV s));
477 generalize in match (N_fresh ? (GV s));intros;
478 rewrite > (? : subst_X s6 c1 s8 = subst_X (subst_X s6 c1 (Par c2)) c2 s8)
479 [rewrite > (? : subst_X s1 c s3 = subst_X (subst_X s1 c (Par c2)) c2 s3)
482 [intro;elim H4;assumption
483 |rewrite > (? : subst_X s c (Par c2) = subst_X s5 c1 (Par c2))
484 [apply pr2_to_pr;apply H6;intro; (* must be fresh in s5 *) elim daemon
485 |(* by Hcut2 *) elim daemon]]
487 |(* as long as it's fresh in s1 too *) elim daemon]
488 |(* as long as it's fresh in s6 too *) elim daemon]
489 |lapply (H4 ? (pr2_to_pr ??? H8));inversion H6;intros;simplify;destruct;
491 generalize in match (p_fresh ? (GV s));
492 generalize in match (N_fresh ? (GV s));intros;
493 rewrite > (? : subst_X s5 c1 (Var (F c1 s5)) = subst_X (subst_X s5 c1 (Par c2)) c2 (Var (F c1 s5)))
494 [rewrite > (? : F c1 s5 = F c2 (subst_X s5 c1 (Par c2)))
495 [rewrite > (? : subst_X s1 c s3 = subst_X (subst_X s1 c (Par c2)) c2 s3)
498 [intro;elim H7;assumption
499 |rewrite > (?: subst_X s c (Par c2) = subst_X s4 c1 (Par c2))
500 [apply pr2_to_pr;apply H10;(* suff fresh *) elim daemon
501 |(* by Hcut1 *) elim daemon]]
503 |(* suff. fresh *) elim daemon]
504 |(* eqvariance *) elim daemon]
505 |(* eqvariance *) elim daemon]]
506 |inversion H6;simplify;intros;destruct;
507 [elim H [3:reflexivity|*:skip]
509 |inversion (pr_to_pr2 ??? H3);simplify;intros;destruct;clear H5;
510 generalize in match (p_fresh ? (GV s));
511 generalize in match (N_fresh ? (GV s));intros;
512 rewrite > (?: subst_X s4 c1 (Var (F c1 s4)) = subst_X (subst_X s4 c1 (Par c2)) c2 (Var (F c1 s4)))
513 [rewrite > (?: subst_X s1 c (Var (F c s1)) = subst_X (subst_X s1 c (Par c2)) c2 (Var (F c s1)))
514 [rewrite > (?: F c1 s4 = F c2 (subst_X s4 c1 (Par c2)))
515 [rewrite > (?: F c s1 = F c2 (subst_X s1 c (Par c2)))
516 [apply pr_xi;apply H2
517 [intro;elim H5;assumption
518 |rewrite > (?: subst_X s c (Par c2) = subst_X s3 c1 (Par c2))
519 [apply pr2_to_pr;apply H4;(*suff. fresh*) elim daemon
520 |(*by Hcut1*)elim daemon]]
521 |(*perm*)elim daemon]
522 |(*perm*)elim daemon]
523 |(*suff.fresh*) elim daemon]
524 |(*suff.fresh*) elim daemon]]
527 lemma diamond_pr : ∀F:xheight.∀a,b,c.a ≫[F] b → a ≫[F] c →
528 ∃d.b ≫[F] d ∧ c ≫[F] d.
531 [cases (cd_exists ?? Hcut) (d);
537 inductive tc (A:Type) (R:A → A → Prop) : A → A → Prop ≝
538 | tc_refl : ∀x:A.tc A R x x
539 | tc_trans : ∀x,y,z.R x y → tc A R y z → tc A R x z.
541 lemma strip_tc_pr : ∀F:xheight.∀a,b,c.pr F a b → tc ? (pr F) a c →
542 ∃d.tc ? (pr F) b d ∧ pr F c d.
543 intros;generalize in match H;generalize in match b;clear H b;elim H1
545 |cases (diamond_pr ???? H H4);cases H5;clear H5;
546 cases (H3 ? H6);cases H5;clear H5;exists[apply x1]
550 lemma diamond_tc_pr : ∀F:xheight.∀a,b,c.tc ? (pr F) a b → tc ? (pr F) a c →
551 ∃d.tc ? (pr F) b d ∧ tc ? (pr F) c d.
552 intros 5;generalize in match c; clear c;elim H
554 |cases (strip_tc_pr ???? H1 H4);cases H5;clear H5;
555 cases (H3 ? H6);cases H5;clear H5;
560 lemma tc_split : ∀A,R,a,b,c.tc A R a b → tc A R b c → tc A R a c.
561 intros 6;elim H;autobatch;
564 lemma tc_single : ∀A,R,a,b.R a b → tc A R a b.
568 lemma tcb_app1 : ∀F:xheight.∀M1,M2,N.tc ? (beta F) M1 M2 → L F N →
569 tc ? (beta F) (App M1 N) (App M2 N).
570 intros;elim H;autobatch;
573 lemma tcb_app2 : ∀F:xheight.∀M,N1,N2.L F M → tc ? (beta F) N1 N2 →
574 tc ? (beta F) (App M N1) (App M N2).
575 intros;elim H1;autobatch;
578 lemma tcb_xi : ∀F:xheight.∀M,N,x.
580 tc ? (beta F) (Abs (F x M) (subst_X M x (Var (F x M))))
581 (Abs (F x N) (subst_X N x (Var (F x N)))).
582 intros;elim H;autobatch;
586 ∀F:xheight.∀x,M,N.L F M →
587 subst_X M x N = subst_Y (subst_X M x (Var (F x M))) (F x M) N.
588 intros;rewrite < subst_X_decompose;
590 |rewrite > L_to_closed;autobatch
595 ∀F:xheight.∀x,M,N.L F M → L F N →
596 beta F (App (Abs (F x M) (subst_X M x (Var (F x M)))) N) (subst_X M x N).
597 intros;rewrite > (red_lemma ???? H) in ⊢ (???%);
598 apply b_redex;autobatch;
601 lemma pr_to_L_1 : ∀F:xheight.∀a,b.a ≫[F] b → L F a.
602 intros;elim H;autobatch;
605 lemma pr_to_L_2 : ∀F:xheight.∀a,b.a ≫[F] b → L F b.
606 intros;elim H;autobatch;
609 lemma pr_to_tc_beta : ∀F:xheight.∀a,b.a ≫[F] b → tc ? (beta F) a b.
612 |apply (tc_split ?????? (?: tc ? (beta F) (App (Abs (F c s) (subst_X s c (Var (F c s)))) s3) ?));
613 [apply tcb_app2;autobatch
614 |apply (tc_split ?????? (?: tc ? (beta F) (App (Abs (F c s1) (subst_X s1 c (Var (F c s1)))) s3) ?));
615 [apply tcb_app1;autobatch
616 |apply tc_single;apply b_redex2;autobatch]]
617 |apply (tc_split ????? (?: tc ?? (App s s2) (App s s3)))
618 [apply tcb_app2;autobatch
619 |apply tcb_app1;autobatch]
623 lemma pr_refl : ∀F:xheight.∀a.L F a → a ≫[F] a.
624 intros;elim H;try autobatch;
627 lemma tc_pr_to_tc_beta: ∀F:xheight.∀a,b.tc ? (pr F) a b → tc ? (beta F) a b.
628 intros;elim H;autobatch;
631 lemma beta_to_pr : ∀F:xheight.∀a,b.a >[F] b → a ≫[F] b.
633 [inversion H1;intros;destruct;
634 rewrite < subst_X_decompose
636 |rewrite > (L_to_closed ?? H3);autobatch
638 |2,3:apply pr_app;autobatch
639 |apply pr_xi;assumption]
642 lemma tc_beta_to_tc_pr: ∀F:xheight.∀a,b.tc ? (beta F) a b → tc ? (pr F) a b.
643 intros;elim H;autobatch;
646 theorem church_rosser:
647 ∀F:xheight.∀a,b,c.tc ? (beta F) a b → tc ? (beta F) a c →
648 ∃d.tc ? (beta F) b d ∧ tc ? (beta F) c d.
649 intros;lapply (tc_beta_to_tc_pr ??? H);lapply (tc_beta_to_tc_pr ??? H1);
650 cases (diamond_tc_pr ???? Hletin Hletin1);cases H2;