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 "delayed_updating/syntax/prototerm_constructors.ma".
16 include "delayed_updating/syntax/prototerm_equivalence.ma".
17 include "delayed_updating/notation/functions/class_d_phi_0.ma".
18 include "ground/xoa/or_5.ma".
19 include "ground/xoa/ex_3_1.ma".
20 include "ground/xoa/ex_4_2.ma".
21 include "ground/xoa/ex_4_3.ma".
22 include "ground/xoa/ex_5_3.ma".
24 (* BY-DEPTH DELAYED (BDD) TERM **********************************************)
26 inductive bdd: π«β¨prototermβ© β
27 | bdd_oref: βn. bdd (#n)
28 | bdd_iref: βt,n. bdd t β bdd (πn.t)
29 | bdd_abst: βt. bdd t β bdd (π.t)
30 | bdd_appl: βu,t. bdd u β bdd t β bdd (@u.t)
31 | bdd_conv: βt1,t2. t1 β t2 β bdd t1 β bdd t2
35 "by-depth delayed (prototerm)"
40 (* Basic inversions *********************************************************)
42 lemma bdd_inv_in_comp_gen:
43 βt,p. t Ο΅ ππ β p Ο΅ t β
44 β¨β¨ ββn. #n β t & π±nβπ = p
45 | ββu,q,n. u Ο΅ ππ & q Ο΅ u & πn.u β t & π±nβπΊβq = p
46 | ββu,q. u Ο΅ ππ & q Ο΅ u & π.u β t & πβq = p
47 | ββv,u,q. v Ο΅ ππ & u Ο΅ ππ & q Ο΅ u & @v.u β t & πβq = p
48 | ββv,u,q. v Ο΅ ππ & u Ο΅ ππ & q Ο΅ v & @v.u β t & π¦βq = p
51 [ #n * /3 width=3 by or5_intro0, ex2_intro/
52 | #u #n #Hu #_ * #q #Hq #Hp /3 width=7 by ex4_3_intro, or5_intro1/
53 | #u #Hu #_ * #q #Hq #Hp /3 width=6 by or5_intro2, ex4_2_intro/
54 | #v #u #Hv #Hu #_ #_ * * #q #Hq #Hp /3 width=8 by ex5_3_intro, or5_intro3, or5_intro4/
55 | #t1 #t2 #Ht12 #_ #IH #Ht2
56 elim IH -IH [6: /2 width=3 by subset_in_eq_repl_fwd/ ] *
57 [ /4 width=3 by subset_eq_trans, or5_intro0, ex2_intro/
58 | /4 width=7 by subset_eq_trans, ex4_3_intro, or5_intro1/
59 | /4 width=6 by subset_eq_trans, or5_intro2, ex4_2_intro/
60 | /4 width=8 by subset_eq_trans, ex5_3_intro, or5_intro3/
61 | /4 width=8 by subset_eq_trans, ex5_3_intro, or5_intro4/
66 lemma bdd_inv_in_comp_d:
67 βt,q,n. t Ο΅ ππ β π±nβq Ο΅ t β
68 β¨β¨ β§β§ #n β t & π = q
69 | ββu. u Ο΅ ππ & q Ο΅ Ι±.u & πn.u β t
72 elim (bdd_inv_in_comp_gen β¦ Ht Hq) -Ht -Hq *
73 [ #n0 #H1 #H2 destruct /3 width=1 by or_introl, conj/
74 | #u0 #q0 #n0 #Hu0 #Hq0 #H1 #H2 destruct
75 /4 width=4 by ex3_intro, ex2_intro, or_intror/
76 | #u0 #q0 #_ #_ #_ #H0 destruct
77 | #v0 #u0 #q0 #_ #_ #_ #_ #H0 destruct
78 | #v0 #u0 #q0 #_ #_ #_ #_ #H0 destruct
82 lemma bdd_inv_in_root_d:
83 βt,q,n. t Ο΅ ππ β π±nβq Ο΅ β΅t β
84 β¨β¨ β§β§ #n β t & π = q
85 | ββu. u Ο΅ ππ & q Ο΅ β΅Ι±.u & πn.u β t
88 elim (bdd_inv_in_comp_d β¦ Ht Hq) -Ht -Hq *
90 elim (eq_inv_list_empty_append β¦ H2) -H2 #H2 #_ destruct
91 /3 width=1 by or_introl, conj/
92 | #u #Hu #Hq #H0 destruct
93 /4 width=4 by ex3_intro, ex_intro, or_intror/
97 lemma bdd_inv_in_comp_L:
98 βt,q. t Ο΅ ππ β πβq Ο΅ t β
99 ββu. u Ο΅ ππ & q Ο΅ u & π.u β t
102 elim (bdd_inv_in_comp_gen β¦ Ht Hq) -Ht -Hq *
103 [ #n0 #_ #H0 destruct
104 | #u0 #q0 #n0 #_ #_ #_ #H0 destruct
105 | #u0 #q0 #Hu0 #Hq0 #H1 #H2 destruct /2 width=4 by ex3_intro/
106 | #v0 #u0 #q0 #_ #_ #_ #_ #H0 destruct
107 | #v0 #u0 #q0 #_ #_ #_ #_ #H0 destruct
111 lemma bdd_inv_in_root_L:
112 βt,q. t Ο΅ ππ β πβq Ο΅ β΅t β
113 ββu. u Ο΅ ππ & q Ο΅ β΅u & π.u β t.
115 elim (bdd_inv_in_comp_L β¦ Ht Hq) -Ht -Hq
116 #u #Hu #Hq #H0 destruct
117 /3 width=4 by ex3_intro, ex_intro/
120 lemma bdd_inv_in_comp_A:
121 βt,q. t Ο΅ ππ β πβq Ο΅ t β
122 ββv,u. v Ο΅ ππ & u Ο΅ ππ & q Ο΅ u & @v.u β t
125 elim (bdd_inv_in_comp_gen β¦ Ht Hq) -Ht -Hq *
126 [ #n0 #_ #H0 destruct
127 | #u0 #q0 #n0 #_ #_ #_ #H0 destruct
128 | #u0 #q0 #_ #_ #_ #H0 destruct
129 | #v0 #u0 #q0 #Hv0 #Hu0 #Hq0 #H1 #H2 destruct /2 width=6 by ex4_2_intro/
130 | #v0 #u0 #q0 #_ #_ #_ #_ #H0 destruct
134 lemma bdd_inv_in_root_A:
135 βt,q. t Ο΅ ππ β πβq Ο΅ β΅t β
136 ββv,u. v Ο΅ ππ & u Ο΅ ππ & q Ο΅ β΅u & @v.u β t
139 elim (bdd_inv_in_comp_A β¦ Ht Hq) -Ht -Hq
140 #v #u #Hv #Hu #Hq #H0 destruct
141 /3 width=6 by ex4_2_intro, ex_intro/
144 lemma bdd_inv_in_comp_S:
145 βt,q. t Ο΅ ππ β π¦βq Ο΅ t β
146 ββv,u. v Ο΅ ππ & u Ο΅ ππ & q Ο΅ v & @v.u β t
149 elim (bdd_inv_in_comp_gen β¦ Ht Hq) -Ht -Hq *
150 [ #n0 #_ #H0 destruct
151 | #u0 #q0 #n0 #_ #_ #_ #H0 destruct
152 | #u0 #q0 #_ #_ #_ #H0 destruct
153 | #v0 #u0 #q0 #_ #_ #_ #_ #H0 destruct
154 | #v0 #u0 #q0 #Hv0 #Hu0 #Hq0 #H1 #H2 destruct /2 width=6 by ex4_2_intro/
158 lemma bdd_inv_in_root_S:
159 βt,q. t Ο΅ ππ β π¦βq Ο΅ β΅t β
160 ββv,u. v Ο΅ ππ & u Ο΅ ππ & q Ο΅ β΅v & @v.u β t
163 elim (bdd_inv_in_comp_S β¦ Ht Hq) -Ht -Hq
164 #v #u #Hv #Hu #Hq #H0 destruct
165 /3 width=6 by ex4_2_intro, ex_intro/
168 (* Advanced inversions ******************************************************)
170 lemma bbd_mono_in_root_d:
171 βl,n,p,t. t Ο΅ ππ β pβπ±n Ο΅ β΅t β pβl Ο΅ β΅t β π±n = l.
173 [ #t #Ht <list_cons_comm <list_cons_comm #Hn #Hl
174 elim (bdd_inv_in_root_d β¦ Ht Hn) -Ht -Hn *
176 lapply (prototerm_root_eq_repl β¦ H0) -H0 #H0
177 lapply (subset_in_eq_repl_fwd ?? β¦ Hl β¦ H0) -H0 -Hl #Hl
178 elim (prototerm_in_root_inv_lcons_oref β¦ Hl) -Hl //
180 lapply (prototerm_root_eq_repl β¦ H0) -H0 #H0
181 lapply (subset_in_eq_repl_fwd ?? β¦ Hl β¦ H0) -H0 -Hl #Hl
182 elim (prototerm_in_root_inv_lcons_iref β¦ Hl) -Hl //
184 | * [ #m ] #p #IH #t #Ht
185 <list_cons_shift <list_cons_shift #Hn #Hl
186 [ elim (bdd_inv_in_root_d β¦ Ht Hn) -Ht -Hn *
188 elim (eq_inv_list_empty_rcons ??? H0)
190 lapply (prototerm_root_eq_repl β¦ H0) -H0 #H0
191 lapply (subset_in_eq_repl_fwd ?? β¦ Hl β¦ H0) -H0 -Hl #Hl
192 elim (prototerm_in_root_inv_lcons_iref β¦ Hl) -Hl #_ #Hl
195 | elim (bdd_inv_in_root_L β¦ Ht Hn) -Ht -Hn
197 lapply (prototerm_root_eq_repl β¦ H0) -H0 #H0
198 lapply (subset_in_eq_repl_fwd ?? β¦ Hl β¦ H0) -H0 -Hl #Hl
199 elim (prototerm_in_root_inv_lcons_abst β¦ Hl) -Hl #_ #Hl
201 | elim (bdd_inv_in_root_A β¦ Ht Hn) -Ht -Hn
203 lapply (prototerm_root_eq_repl β¦ H0) -H0 #H0
204 lapply (subset_in_eq_repl_fwd ?? β¦ Hl β¦ H0) -H0 -Hl #Hl
205 elim (prototerm_in_root_inv_lcons_appl β¦ Hl) -Hl * #H0 #Hl destruct
207 | elim (bdd_inv_in_root_S β¦ Ht Hn) -Ht -Hn
209 lapply (prototerm_root_eq_repl β¦ H0) -H0 #H0
210 lapply (subset_in_eq_repl_fwd ?? β¦ Hl β¦ H0) -H0 -Hl #Hl
211 elim (prototerm_in_root_inv_lcons_appl β¦ Hl) -Hl * #H0 #Hl destruct