]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/static_2/syntax/lveq_length.ma
partial update in static_2
[helm.git] / matita / matita / contribs / lambdadelta / static_2 / syntax / lveq_length.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/arith/nat_le_minus_plus.ma".
16 include "static_2/syntax/lenv_length.ma".
17 include "static_2/syntax/lveq.ma".
18
19 (* EQUIVALENCE FOR LOCAL ENVIRONMENTS UP TO EXCLUSION BINDERS ***************)
20
21 (* Properties with length for local environments ****************************)
22
23 lemma lveq_length_eq: โˆ€L1,L2. |L1| = |L2| โ†’ L1 โ‰‹โ“ง*[๐ŸŽ,๐ŸŽ] L2.
24 #L1 elim L1 -L1
25 [ #Y2 #H >(length_inv_zero_sn โ€ฆ H) -Y2 /2 width=3 by lveq_atom, ex_intro/
26 | #K1 #I1 #IH #Y2 #H
27   elim (length_inv_succ_sn โ€ฆ H) -H #I2 #K2 #HK #H destruct
28   /3 width=1 by lveq_bind/
29 ]
30 qed.
31
32 (* Forward lemmas with length for local environments ************************)
33
34 lemma lveq_fwd_length_le_sn: โˆ€L1,L2,n1,n2. L1 โ‰‹โ“ง*[n1,n2] L2 โ†’ n1 โ‰ค |L1|.
35 #L1 #L2 #n1 #n2 #H elim H -L1 -L2 -n1 -n2
36 /2 width=1 by nle_succ_bi/
37 qed-.
38
39 lemma lveq_fwd_length_le_dx: โˆ€L1,L2,n1,n2. L1 โ‰‹โ“ง*[n1,n2] L2 โ†’ n2 โ‰ค |L2|.
40 #L1 #L2 #n1 #n2 #H elim H -L1 -L2 -n1 -n2
41 /2 width=1 by nle_succ_bi/
42 qed-.
43
44 lemma lveq_fwd_length: โˆ€L1,L2,n1,n2. L1 โ‰‹โ“ง*[n1,n2] L2 โ†’
45                        โˆงโˆง |L1|-|L2| = n1 & |L2|-|L1| = n2.
46 #L1 #L2 #n1 #n2 #H elim H -L1 -L2 -n1 -n2
47 [ /2 width=1 by conj/
48 | #I1 #I2 #K1 #K2 #_ #IH >length_bind >length_bind //
49 ]
50 #K1 #K2 #n #_ * #H1 #H2 destruct
51 >length_bind <nminus_succ_dx <nminus_succ_sn
52 /2 width=1 by nle_eq_zero_minus, conj/
53 qed-.
54
55 lemma lveq_length_fwd_sn: โˆ€L1,L2,n1,n2. L1 โ‰‹โ“ง*[n1,n2] L2 โ†’ |L1| โ‰ค |L2| โ†’ ๐ŸŽ = n1.
56 #L1 #L2 #n1 #n2 #H #HL
57 elim (lveq_fwd_length โ€ฆ H) -H
58 >(nle_inv_eq_zero_minus โ€ฆ HL) //
59 qed-.
60
61 lemma lveq_length_fwd_dx: โˆ€L1,L2,n1,n2. L1 โ‰‹โ“ง*[n1,n2] L2 โ†’ |L2| โ‰ค |L1| โ†’ ๐ŸŽ = n2.
62 #L1 #L2 #n1 #n2 #H #HL
63 elim (lveq_fwd_length โ€ฆ H) -H
64 >(nle_inv_eq_zero_minus โ€ฆ HL) //
65 qed-.
66
67 lemma lveq_inj_length: โˆ€L1,L2,n1,n2. L1 โ‰‹โ“ง*[n1,n2] L2 โ†’
68                        |L1| = |L2| โ†’ โˆงโˆง ๐ŸŽ = n1 & ๐ŸŽ = n2.
69 #L1 #L2 #n1 #n2 #H #HL
70 elim (lveq_fwd_length โ€ฆ H) -H
71 >HL -HL /2 width=1 by conj/
72 qed-.
73
74 lemma lveq_fwd_length_plus: โˆ€L1,L2,n1,n2. L1 โ‰‹โ“ง*[n1,n2] L2 โ†’
75                             |L1| + n2 = |L2| + n1.
76 #L1 #L2 #n1 #n2 #H elim H -L1 -L2 -n1 -n2 //
77 #k1 #K2 #n #_ #IH <nplus_succ_dx //
78 qed-.
79
80 lemma lveq_fwd_length_eq: โˆ€L1,L2. L1 โ‰‹โ“ง*[๐ŸŽ,๐ŸŽ] L2 โ†’ |L1| = |L2|.
81 /3 width=2 by lveq_fwd_length_plus, eq_inv_nplus_bi_dx/ qed-.
82
83 lemma lveq_fwd_length_minus: โˆ€L1,L2,n1,n2. L1 โ‰‹โ“ง*[n1,n2] L2 โ†’
84                              |L1| - n1 = |L2| - n2.
85 /3 width=3 by lveq_fwd_length_plus, lveq_fwd_length_le_dx, lveq_fwd_length_le_sn, nminus_plus_swap/ qed-.
86
87 lemma lveq_fwd_abst_bind_length_le: โˆ€I1,I2,L1,L2,V1,n1,n2.
88                                     L1.โ“‘[I1]V1 โ‰‹โ“ง*[n1,n2] L2.โ“˜[I2] โ†’ |L1| โ‰ค |L2|.
89 #I1 #I2 #L1 #L2 #V1 #n1 #n2 #HL
90 lapply (lveq_fwd_pair_sn โ€ฆ HL) #H destruct
91 elim (lveq_fwd_length โ€ฆ HL) -HL >length_bind >length_bind
92 <nminus_succ_bi <nminus_succ_bi //
93 qed-.
94
95 lemma lveq_fwd_bind_abst_length_le: โˆ€I1,I2,L1,L2,V2,n1,n2.
96                                     L1.โ“˜[I1] โ‰‹โ“ง*[n1,n2] L2.โ“‘[I2]V2 โ†’ |L2| โ‰ค |L1|.
97 /3 width=6 by lveq_fwd_abst_bind_length_le, lveq_sym/ qed-.
98
99 (* Inversion lemmas with length for local environments **********************)
100
101 (**) (* state with m2 โ‰ โ†“n2 *)
102 lemma lveq_inv_void_dx_length: โˆ€L1,L2,n1,n2. L1 โ‰‹โ“ง*[n1,n2] L2.โ“ง โ†’ |L1| โ‰ค |L2| โ†’
103                                โˆƒโˆƒm2. L1 โ‰‹ โ“ง*[n1,m2] L2 & ๐ŸŽ = n1 & โ†‘m2 = n2.
104 #L1 #L2 #n1 #n2 #H #HL12
105 lapply (lveq_fwd_length_plus โ€ฆ H) >length_bind >nplus_succ_shift #H0
106 lapply (nplus_2_des_le_sn_sn โ€ฆ H0 HL12) -H0 -HL12 #H0
107 elim (nle_inv_succ_sn โ€ฆ H0) -H0 #_ #H0 >H0 in H; -H0 #H
108 elim (lveq_inv_void_succ_dx โ€ฆ H) -H /2 width=3 by ex3_intro/
109 qed-.
110
111 (**) (* state with m1 โ‰ โ†“n1 *)
112 lemma lveq_inv_void_sn_length: โˆ€L1,L2,n1,n2. L1.โ“ง โ‰‹โ“ง*[n1,n2] L2 โ†’ |L2| โ‰ค |L1| โ†’
113                                โˆƒโˆƒm1. L1 โ‰‹ โ“ง*[m1,n2] L2 & โ†‘m1 = n1 & ๐ŸŽ = n2.
114 #L1 #L2 #n1 #n2 #H #HL
115 lapply (lveq_sym โ€ฆ H) -H #H
116 elim (lveq_inv_void_dx_length โ€ฆ H HL) -H -HL
117 /3 width=4 by lveq_sym, ex3_intro/
118 qed-.