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/normal_5.ma".
16 include "basic_2/reduction/cnr.ma".
17 include "basic_2/reduction/cpx.ma".
19 (* CONTEXT-SENSITIVE EXTENDED NORMAL TERMS **********************************)
21 definition cnx: ∀h. sd h → relation3 genv lenv term ≝
22 λh,g,G,L. NF … (cpx h g G L) (eq …).
25 "context-sensitive extended normality (term)"
26 'Normal h g L T = (cnx h g L T).
28 (* Basic inversion lemmas ***************************************************)
30 lemma cnx_inv_sort: ∀h,g,G,L,k. ⦃G, L⦄ ⊢ 𝐍[h, g]⦃⋆k⦄ → deg h g k 0.
31 #h #g #G #L #k #H elim (deg_total h g k)
32 #l @(nat_ind_plus … l) -l // #l #_ #Hkl
33 lapply (H (⋆(next h k)) ?) -H /2 width=2/ -L -l #H destruct -H -e0 (**) (* destruct does not remove some premises *)
34 lapply (next_lt h k) >e1 -e1 #H elim (lt_refl_false … H)
37 lemma cnx_inv_delta: ∀h,g,I,G,L,K,V,i. ⇩[0, i] L ≡ K.ⓑ{I}V → ⦃G, L⦄ ⊢ 𝐍[h, g]⦃#i⦄ → ⊥.
38 #h #g #I #G #L #K #V #i #HLK #H
39 elim (lift_total V 0 (i+1)) #W #HVW
40 lapply (H W ?) -H [ /3 width=7/ ] -HLK #H destruct
41 elim (lift_inv_lref2_be … HVW) -HVW //
44 lemma cnx_inv_abst: ∀h,g,a,G,L,V,T. ⦃G, L⦄ ⊢ 𝐍[h, g]⦃ⓛ{a}V.T⦄ →
45 ⦃G, L⦄ ⊢ 𝐍[h, g]⦃V⦄ ∧ ⦃G, L.ⓛV⦄ ⊢ 𝐍[h, g]⦃T⦄.
46 #h #g #a #G #L #V1 #T1 #HVT1 @conj
47 [ #V2 #HV2 lapply (HVT1 (ⓛ{a}V2.T1) ?) -HVT1 /2 width=2/ -HV2 #H destruct //
48 | #T2 #HT2 lapply (HVT1 (ⓛ{a}V1.T2) ?) -HVT1 /2 width=2/ -HT2 #H destruct //
52 lemma cnx_inv_abbr: ∀h,g,G,L,V,T. ⦃G, L⦄ ⊢ 𝐍[h, g]⦃-ⓓV.T⦄ →
53 ⦃G, L⦄ ⊢ 𝐍[h, g]⦃V⦄ ∧ ⦃G, L.ⓓV⦄ ⊢ 𝐍[h, g]⦃T⦄.
54 #h #g #G #L #V1 #T1 #HVT1 @conj
55 [ #V2 #HV2 lapply (HVT1 (-ⓓV2.T1) ?) -HVT1 /2 width=2/ -HV2 #H destruct //
56 | #T2 #HT2 lapply (HVT1 (-ⓓV1.T2) ?) -HVT1 /2 width=2/ -HT2 #H destruct //
60 lemma cnx_inv_zeta: ∀h,g,G,L,V,T. ⦃G, L⦄ ⊢ 𝐍[h, g]⦃+ⓓV.T⦄ → ⊥.
61 #h #g #G #L #V #T #H elim (is_lift_dec T 0 1)
63 lapply (H U ?) -H /2 width=3/ #H destruct
64 elim (lift_inv_pair_xy_y … HTU)
66 elim (cpr_delift G(⋆) V T (⋆.ⓓV) 0) // #T2 #T1 #HT2 #HT12
67 lapply (H (+ⓓV.T2) ?) -H /5 width=1/ -HT2 #H destruct /3 width=2/
71 lemma cnx_inv_appl: ∀h,g,G,L,V,T. ⦃G, L⦄ ⊢ 𝐍[h, g]⦃ⓐV.T⦄ →
72 ∧∧ ⦃G, L⦄ ⊢ 𝐍[h, g]⦃V⦄ & ⦃G, L⦄ ⊢ 𝐍[h, g]⦃T⦄ & 𝐒⦃T⦄.
73 #h #g #G #L #V1 #T1 #HVT1 @and3_intro
74 [ #V2 #HV2 lapply (HVT1 (ⓐV2.T1) ?) -HVT1 /2 width=1/ -HV2 #H destruct //
75 | #T2 #HT2 lapply (HVT1 (ⓐV1.T2) ?) -HVT1 /2 width=1/ -HT2 #H destruct //
76 | generalize in match HVT1; -HVT1 elim T1 -T1 * // #a * #W1 #U1 #_ #_ #H
77 [ elim (lift_total V1 0 1) #V2 #HV12
78 lapply (H (ⓓ{a}W1.ⓐV2.U1) ?) -H /3 width=3/ -HV12 #H destruct
79 | lapply (H (ⓓ{a}ⓝW1.V1.U1) ?) -H /3 width=1/ #H destruct
83 lemma cnx_inv_tau: ∀h,g,G,L,V,T. ⦃G, L⦄ ⊢ 𝐍[h, g]⦃ⓝV.T⦄ → ⊥.
84 #h #g #G #L #V #T #H lapply (H T ?) -H /2 width=1/ #H
88 (* Basic forward lemmas *****************************************************)
90 lemma cnx_fwd_cnr: ∀h,g,G,L,T. ⦃G, L⦄ ⊢ 𝐍[h, g]⦃T⦄ → ⦃G, L⦄ ⊢ 𝐍⦃T⦄.
91 #h #g #G #L #T #H #U #HTU
92 @H /2 width=1/ (**) (* auto fails because a δ-expansion gets in the way *)
95 (* Basic properties *********************************************************)
97 lemma cnx_sort: ∀h,g,G,L,k. deg h g k 0 → ⦃G, L⦄ ⊢ 𝐍[h, g]⦃⋆k⦄.
98 #h #g #G #L #k #Hk #X #H elim (cpx_inv_sort1 … H) -H // * #l #Hkl #_
99 lapply (deg_mono … Hkl Hk) -h -L <plus_n_Sm #H destruct
102 lemma cnx_sort_iter: ∀h,g,G,L,k,l. deg h g k l → ⦃G, L⦄ ⊢ 𝐍[h, g]⦃⋆((next h)^l k)⦄.
103 #h #g #G #L #k #l #Hkl
104 lapply (deg_iter … l Hkl) -Hkl <minus_n_n /2 width=1/
107 lemma cnx_abst: ∀h,g,a,G,L,W,T. ⦃G, L⦄ ⊢ 𝐍[h, g]⦃W⦄ → ⦃G, L.ⓛW⦄ ⊢ 𝐍[h, g]⦃T⦄ →
108 ⦃G, L⦄ ⊢ 𝐍[h, g]⦃ⓛ{a}W.T⦄.
109 #h #g #a #G #L #W #T #HW #HT #X #H
110 elim (cpx_inv_abst1 … H) -H #W0 #T0 #HW0 #HT0 #H destruct
111 >(HW … HW0) -W0 >(HT … HT0) -T0 //
114 lemma cnx_appl_simple: ∀h,g,G,L,V,T. ⦃G, L⦄ ⊢ 𝐍[h, g]⦃V⦄ → ⦃G, L⦄ ⊢ 𝐍[h, g]⦃T⦄ → 𝐒⦃T⦄ →
115 ⦃G, L⦄ ⊢ 𝐍[h, g]⦃ⓐV.T⦄.
116 #h #g #G #L #V #T #HV #HT #HS #X #H
117 elim (cpx_inv_appl1_simple … H) -H // #V0 #T0 #HV0 #HT0 #H destruct
118 >(HV … HV0) -V0 >(HT … HT0) -T0 //
121 axiom cnx_dec: ∀h,g,G,L,T1. ⦃G, L⦄ ⊢ 𝐍[h, g]⦃T1⦄ ∨
122 ∃∃T2. ⦃G, L⦄ ⊢ T1 ➡[h, g] T2 & (T1 = T2 → ⊥).