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 "basic_2/notation/relations/topiso_4.ma".
16 include "basic_2/syntax/item_sd.ma".
17 include "basic_2/syntax/term.ma".
19 (* SAME TOP TERM STRUCTURE **************************************************)
21 (* Basic_2A1: includes: tsts_atom *)
22 inductive tsts (h) (o): relation term ≝
23 | tsts_sort: ∀s1,s2,d. deg h o s1 d → deg h o s2 d → tsts h o (⋆s1) (⋆s2)
24 | tsts_lref: ∀i. tsts h o (#i) (#i)
25 | tsts_gref: ∀l. tsts h o (§l) (§l)
26 | tsts_pair: ∀I,V1,V2,T1,T2. tsts h o (②{I}V1.T1) (②{I}V2.T2)
29 interpretation "same top structure (term)" 'TopIso h o T1 T2 = (tsts h o T1 T2).
31 (* Basic inversion lemmas ***************************************************)
33 fact tsts_inv_sort1_aux: ∀h,o,X,Y. X ⩳[h, o] Y → ∀s1. X = ⋆s1 →
34 ∃∃s2,d. deg h o s1 d & deg h o s2 d & Y = ⋆s2.
36 [ #s1 #s2 #d #Hs1 #Hs2 #s #H destruct /2 width=5 by ex3_2_intro/
39 | #I #V1 #V2 #T1 #T2 #s #H destruct
43 (* Basic_1: was just: iso_gen_sort *)
44 lemma tsts_inv_sort1: ∀h,o,Y,s1. ⋆s1 ⩳[h, o] Y →
45 ∃∃s2,d. deg h o s1 d & deg h o s2 d & Y = ⋆s2.
46 /2 width=3 by tsts_inv_sort1_aux/ qed-.
48 fact tsts_inv_lref1_aux: ∀h,o,X,Y. X ⩳[h, o] Y → ∀i. X = #i → Y = #i.
49 #h #o #X #Y * -X -Y //
50 [ #s1 #s2 #d #_ #_ #j #H destruct
51 | #I #V1 #V2 #T1 #T2 #j #H destruct
55 (* Basic_1: was: iso_gen_lref *)
56 lemma tsts_inv_lref1: ∀h,o,Y,i. #i ⩳[h, o] Y → Y = #i.
57 /2 width=5 by tsts_inv_lref1_aux/ qed-.
59 fact tsts_inv_gref1_aux: ∀h,o,X,Y. X ⩳[h, o] Y → ∀l. X = §l → Y = §l.
60 #h #o #X #Y * -X -Y //
61 [ #s1 #s2 #d #_ #_ #k #H destruct
62 | #I #V1 #V2 #T1 #T2 #k #H destruct
66 lemma tsts_inv_gref1: ∀h,o,Y,l. §l ⩳[h, o] Y → Y = §l.
67 /2 width=5 by tsts_inv_gref1_aux/ qed-.
69 fact tsts_inv_pair1_aux: ∀h,o,T1,T2. T1 ⩳[h, o] T2 →
70 ∀I,W1,U1. T1 = ②{I}W1.U1 →
71 ∃∃W2,U2. T2 = ②{I}W2.U2.
72 #h #o #T1 #T2 * -T1 -T2
73 [ #s1 #s2 #d #_ #_ #J #W1 #U1 #H destruct
74 | #i #J #W1 #U1 #H destruct
75 | #l #J #W1 #U1 #H destruct
76 | #I #V1 #V2 #T1 #T2 #J #W1 #U1 #H destruct /2 width=3 by ex1_2_intro/
80 (* Basic_1: was: iso_gen_head *)
81 lemma tsts_inv_pair1: ∀h,o,J,W1,U1,T2. ②{J}W1.U1 ⩳[h, o] T2 →
82 ∃∃W2,U2. T2 = ②{J}W2. U2.
83 /2 width=7 by tsts_inv_pair1_aux/ qed-.
85 (* Advanced inversion lemmas ************************************************)
87 lemma tsts_inv_sort1_deg: ∀h,o,Y,s1. ⋆s1 ⩳[h, o] Y → ∀d. deg h o s1 d →
88 ∃∃s2. deg h o s2 d & Y = ⋆s2.
89 #h #o #Y #s1 #H #d #Hs1 elim (tsts_inv_sort1 … H) -H
90 #s2 #x #Hx <(deg_mono h o … Hx … Hs1) -s1 -d /2 width=3 by ex2_intro/
93 lemma tsts_inv_sort_deg: ∀h,o,s1,s2. ⋆s1 ⩳[h, o] ⋆s2 →
94 ∀d1,d2. deg h o s1 d1 → deg h o s2 d2 →
96 #h #o #s1 #y #H #d1 #d2 #Hs1 #Hy
97 elim (tsts_inv_sort1_deg … H … Hs1) -s1 #s2 #Hs2 #H destruct
98 <(deg_mono h o … Hy … Hs2) -s2 -d1 //
101 lemma tsts_inv_pair: ∀h,o,I1,I2,V1,V2,T1,T2. ②{I1}V1.T1 ⩳[h, o] ②{I2}V2.T2 →
103 #h #o #I1 #I2 #V1 #V2 #T1 #T2 #H elim (tsts_inv_pair1 … H) -H
104 #V0 #T0 #H destruct //
107 (* Basic properties *********************************************************)
109 (* Basic_1: was: iso_refl *)
110 lemma tsts_refl: ∀h,o. reflexive … (tsts h o).
112 * /2 width=1 by tsts_lref, tsts_gref/
113 #s elim (deg_total h o s) /2 width=3 by tsts_sort/
116 lemma tsts_sym: ∀h,o. symmetric … (tsts h o).
117 #h #o #T1 #T2 * -T1 -T2 /2 width=3 by tsts_sort/
120 lemma tsts_dec: ∀h,o,T1,T2. Decidable (T1 ⩳[h, o] T2).
121 #h #o * [ * #s1 | #I1 #V1 #T1 ] * [1,3,5,7: * #s2 |*: #I2 #V2 #T2 ]
122 [ elim (deg_total h o s1) #d1 #H1
123 elim (deg_total h o s2) #d2 #H2
124 elim (eq_nat_dec d1 d2) #Hd12 destruct /3 width=3 by tsts_sort, or_introl/
126 lapply (tsts_inv_sort_deg … H … H1 H2) -H -H1 -H2 /2 width=1 by/
129 elim (tsts_inv_sort1 … H) -H #x1 #x2 #_ #_ #H destruct
132 lapply (tsts_inv_lref1 … H) -H #H destruct
134 elim (eq_nat_dec s1 s2) #Hs12 destruct /2 width=1 by or_introl/
136 lapply (tsts_inv_lref1 … H) -H #H destruct /2 width=1 by/
139 lapply (tsts_inv_gref1 … H) -H #H destruct
141 elim (eq_nat_dec s1 s2) #Hs12 destruct /2 width=1 by or_introl/
143 lapply (tsts_inv_gref1 … H) -H #H destruct /2 width=1 by/
146 elim (tsts_inv_pair1 … H) -H #X1 #X2 #H destruct
148 elim (eq_item2_dec I1 I2) #HI12 destruct
149 [ /3 width=1 by tsts_pair, or_introl/ ]
151 lapply (tsts_inv_pair … H) -H /2 width=1 by/
155 (* Basic_2A1: removed theorems 4:
156 tsts_inv_atom1 tsts_inv_atom2