]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/basic_2/grammar/leq.ma
theory of cpy is complete!
[helm.git] / matita / matita / contribs / lambdadelta / basic_2 / grammar / leq.ma
1 (**************************************************************************)
2 (*       ___                                                              *)
3 (*      ||M||                                                             *)
4 (*      ||A||       A project by Andrea Asperti                           *)
5 (*      ||T||                                                             *)
6 (*      ||I||       Developers:                                           *)
7 (*      ||T||         The HELM team.                                      *)
8 (*      ||A||         http://helm.cs.unibo.it                             *)
9 (*      \   /                                                             *)
10 (*       \ /        This file is distributed under the terms of the       *)
11 (*        v         GNU General Public License Version 2                  *)
12 (*                                                                        *)
13 (**************************************************************************)
14
15 include "ground_2/ynat/ynat_succ.ma".
16 include "basic_2/notation/relations/iso_4.ma".
17 include "basic_2/grammar/lenv_length.ma".
18
19 (* EQUIVALENCE FOR LOCAL ENVIRONMENTS ***************************************)
20
21 inductive leq: ynat → ynat → relation lenv ≝
22 | leq_atom: ∀d,e. leq d e (⋆) (⋆)
23 | leq_zero: ∀I,L1,L2,V. leq 0 0 L1 L2 → leq 0 0 (L1.ⓑ{I}V) (L2.ⓑ{I}V)
24 | leq_pair: ∀I1,I2,L1,L2,V1,V2,e.
25             leq 0 e L1 L2 → leq 0 (⫯e) (L1.ⓑ{I1}V1) (L2.ⓑ{I2}V2)
26 | leq_succ: ∀I,L1,L2,V,d,e. leq d e L1 L2 → leq (⫯d) e (L1.ⓑ{I}V) (L2.ⓑ{I}V)
27 .
28
29 interpretation
30    "equivalence (local environment)"
31    'Iso d e L1 L2 = (leq d e L1 L2).
32
33 (* Basic properties *********************************************************)
34
35 lemma leq_refl: ∀L,d,e. L ≃[d, e] L.
36 #L elim L -L /2 width=1 by/
37 #L #I #V #IHL #d #e elim (ynat_cases … d) [ | * /2 width=1 by leq_succ/ ]
38 elim (ynat_cases … e) [ | * ]
39 /2 width=1 by leq_zero, leq_pair/
40 qed.
41
42 lemma leq_sym: ∀L1,L2,d,e. L1 ≃[d, e] L2 → L2 ≃[d, e] L1.
43 #L1 #L2 #d #e #H elim H -L1 -L2 -d -e
44 /2 width=1 by leq_atom, leq_zero, leq_pair, leq_succ/
45 qed-.
46
47 lemma leq_O_Y: ∀L1,L2. |L1| = |L2| → L1 ≃[0, ∞] L2.
48 #L1 elim L1 -L1
49 [ #X #H lapply (length_inv_zero_sn … H) -H //
50 | #L1 #I1 #V1 #IHL1 #X #H elim (length_inv_pos_sn … H) -H
51   #L2 #I2 #V2 #HL12 #H destruct
52   @(leq_pair … (∞)) /2 width=1 by/ (**) (* explicit constructor *)
53 ]
54 qed.
55
56 (* Basic forward lemmas *****************************************************)
57
58 lemma leq_fwd_length: ∀L1,L2,d,e. L1 ≃[d, e] L2 → |L1| = |L2|.
59 #L1 #L2 #d #e #H elim H -L1 -L2 -d -e normalize //
60 qed-.
61
62 (* Basic inversion lemmas ***************************************************)
63
64 fact leq_inv_O2_aux: ∀L1,L2,d,e. L1 ≃[d, e] L2 → e = 0 → L1 = L2.
65 #L1 #L2 #d #e #H elim H -L1 -L2 -d -e /3 width=1 by eq_f3/
66 #I1 #I2 #L1 #L2 #V1 #V2 #e #_ #_ #H elim (ysucc_inv_O_dx … H)
67 qed-.
68
69 lemma leq_inv_O2: ∀L1,L2,d. L1 ≃[d, 0] L2 → L1 = L2.
70 /2 width=4 by leq_inv_O2_aux/ qed-.
71
72 fact leq_inv_Y1_aux: ∀L1,L2,d,e. L1 ≃[d, e] L2 → d = ∞ → L1 = L2.
73 #L1 #L2 #d #e #H elim H -L1 -L2 -d -e /3 width=1 by eq_f3/
74 [ #I1 #I2 #L1 #L2 #V1 #V2 #e #_ #_ #H destruct
75 | #I #L1 #L2 #V #d #e #_ #IHL12 #H lapply (ysucc_inv_Y_dx … H) -H
76   /3 width=1 by eq_f3/
77 ]
78 qed-.
79
80 lemma leq_inv_Y1: ∀L1,L2,e. L1 ≃[∞, e] L2 → L1 = L2.
81 /2 width=4 by leq_inv_Y1_aux/ qed-.