]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/basic_2/computation/gcp_cr.ma
537769345a22cbe98e506b605df501148283b591
[helm.git] / matita / matita / contribs / lambdadelta / basic_2 / computation / gcp_cr.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 "basic_2/notation/relations/ineint_5.ma".
16 include "basic_2/grammar/aarity.ma".
17 include "basic_2/multiple/mr2_mr2.ma".
18 include "basic_2/multiple/lifts_lift_vector.ma".
19 include "basic_2/multiple/drops_drop.ma".
20 include "basic_2/computation/gcp.ma".
21
22 (* GENERIC COMPUTATION PROPERTIES *******************************************)
23
24 definition S0 ≝ λC:candidate. ∀G,L2,L1,T1,d,e.
25                 C G L1 T1 → ∀T2. ⇩[Ⓕ, d, e] L2 ≡ L1 → ⇧[d, e] T1 ≡ T2 → C G L2 T2.
26
27 definition S0s ≝ λC:candidate.
28                  ∀G,L1,L2,des. ⇩*[Ⓕ, des] L2 ≡ L1 →
29                  ∀T1,T2. ⇧*[des] T1 ≡ T2 → C G L1 T1 → C G L2 T2.
30
31 (* Note: this is Girard's CR1 *)
32 definition S1 ≝ λRP,C:candidate.
33                 ∀G,L,T. C G L T → RP G L T.
34
35 (* Note: this is Tait's iii, or Girard's CR4 *)
36 definition S2 ≝ λRR:relation4 genv lenv term term. λRS:relation term. λRP,C:candidate.
37                 ∀G,L,Vs. all … (RP G L) Vs →
38                 ∀T. 𝐒⦃T⦄ → NF … (RR G L) RS T → C G L (ⒶVs.T).
39
40 (* Note: this generalizes Tait's ii *)
41 definition S3 ≝ λC:candidate.
42                 ∀a,G,L,Vs,V,T,W.
43                 C G L (ⒶVs.ⓓ{a}ⓝW.V.T) → C G L (ⒶVs.ⓐV.ⓛ{a}W.T).
44
45 definition S4 ≝ λRP,C:candidate.
46                 ∀G,L,Vs. all … (RP G L) Vs → ∀k. C G L (ⒶVs.⋆k).
47
48 definition S5 ≝ λC:candidate. ∀I,G,L,K,Vs,V1,V2,i.
49                 C G L (ⒶVs.V2) → ⇧[0, i+1] V1 ≡ V2 →
50                 ⇩[i] L ≡ K.ⓑ{I}V1 → C G L (ⒶVs.#i).
51
52 definition S6 ≝ λRP,C:candidate.
53                 ∀G,L,V1s,V2s. ⇧[0, 1] V1s ≡ V2s →
54                 ∀a,V,T. C G (L.ⓓV) (ⒶV2s.T) → RP G L V → C G L (ⒶV1s.ⓓ{a}V.T).
55
56 definition S7 ≝ λC:candidate.
57                 ∀G,L,Vs,T,W. C G L (ⒶVs.T) → C G L (ⒶVs.W) → C G L (ⒶVs.ⓝW.T).
58
59 (* requirements for the generic reducibility candidate *)
60 record gcr (RR:relation4 genv lenv term term) (RS:relation term) (RP,C:candidate) : Prop ≝
61 { s0: S0 C;
62   s1: S1 RP C;
63   s2: S2 RR RS RP C;
64   s3: S3 C;
65   s4: S4 RP C;
66   s5: S5 C;
67   s6: S6 RP C;
68   s7: S7 C
69 }.
70
71 (* the functional construction for candidates *)
72 definition cfun: candidate → candidate → candidate ≝
73                  λC1,C2,G,K,T. ∀L,V,U,des.
74                  ⇩*[Ⓕ, des] L ≡ K → ⇧*[des] T ≡ U → C1 G L V → C2 G L (ⓐV.U).
75
76 (* the reducibility candidate associated to an atomic arity *)
77 let rec acr (RP:candidate) (A:aarity) on A: candidate ≝
78 match A with
79 [ AAtom     ⇒ RP
80 | APair B A ⇒ cfun (acr RP B) (acr RP A)
81 ].
82
83 interpretation
84    "candidate of reducibility of an atomic arity (abstract)"
85    'InEInt RP G L T A = (acr RP A G L T).
86
87 (* Basic properties *********************************************************)
88
89 (* Basic_1: was: sc3_lift1 *)
90 lemma gcr_lifts: ∀C. S0 C → S0s C.
91 #C #HC #G #L1 #L2 #des #H elim H -L1 -L2 -des
92 [ #L #T1 #T2 #H #HT1 <(lifts_inv_nil … H) -H //
93 | #L1 #L #L2 #des #d #e #_ #HL2 #IHL #T2 #T1 #H #HLT2
94   elim (lifts_inv_cons … H) -H /3 width=10 by/
95 ]
96 qed.
97
98 lemma rp_lifts: ∀RR,RS,RP. gcr RR RS RP RP →
99                 ∀des,G,L0,L,V,V0. ⇩*[Ⓕ, des] L0 ≡ L → ⇧*[des] V ≡ V0 →
100                 RP G L V → RP G L0 V0.
101 #RR #RS #RP #HRP #des #G #L0 #L #V #V0 #HL0 #HV0 #HV
102 @gcr_lifts /width=7 by/
103 @(s0 … HRP)
104 qed.
105
106 (* Basic_1: was only: sns3_lifts1 *)
107 lemma rp_liftsv_all: ∀RR,RS,RP. gcr RR RS RP RP →
108                      ∀des,G,L0,L,Vs,V0s. ⇩*[Ⓕ, des] L0 ≡ L → ⇧*[des] Vs ≡ V0s →
109                      all … (RP G L) Vs → all … (RP G L0) V0s.
110 #RR #RS #RP #HRP #des #G #L0 #L #Vs #V0s #HL0 #H elim H -Vs -V0s normalize //
111 #T1s #T2s #T1 #T2 #HT12 #_ #IHT2s * /3 width=7 by rp_lifts, conj/
112 qed.
113
114 (* Basic_1: was:
115    sc3_sn3 sc3_abst sc3_appl sc3_abbr sc3_bind sc3_cast sc3_lift
116 *)
117 lemma acr_gcr: ∀RR,RS,RP. gcp RR RS RP → gcr RR RS RP RP →
118                ∀A. gcr RR RS RP (acr RP A).
119 #RR #RS #RP #H1RP #H2RP #A elim A -A normalize //
120 #B #A #IHB #IHA @mk_gcr normalize
121 [ /3 width=7 by drops_cons, lifts_cons/
122 | #G #L #T #H
123   elim (cp1 … H1RP G L) #k #HK
124   lapply (H ? (⋆k) ? (⟠) ? ? ?) -H
125   [3,5: // |2,4: skip
126   | @(s2 … IHB … (◊)) //
127   | #H @(cp2 … H1RP … k) @(s1 … IHA) //
128   ]
129 | #G #L #Vs #HVs #T #H1T #H2T #L0 #V0 #X #des #HL0 #H #HB
130   elim (lifts_inv_applv1 … H) -H #V0s #T0 #HV0s #HT0 #H destruct
131   lapply (s1 … IHB … HB) #HV0
132   @(s2 … IHA … (V0 @ V0s))
133   /3 width=14 by rp_liftsv_all, gcp_lifts, cp0, lifts_simple_dx, conj/
134 | #a #G #L #Vs #U #T #W #HA #L0 #V0 #X #des #HL0 #H #HB
135   elim (lifts_inv_applv1 … H) -H #V0s #Y #HV0s #HY #H destruct
136   elim (lifts_inv_flat1 … HY) -HY #U0 #X #HU0 #HX #H destruct
137   elim (lifts_inv_bind1 … HX) -HX #W0 #T0 #HW0 #HT0 #H destruct
138   @(s3 … IHA … (V0 @ V0s)) /5 width=6 by lifts_applv, lifts_flat, lifts_bind/
139 | #G #L #Vs #HVs #k #L0 #V0 #X #des #HL0 #H #HB
140   elim (lifts_inv_applv1 … H) -H #V0s #Y #HV0s #HY #H destruct
141   >(lifts_inv_sort1 … HY) -Y
142   lapply (s1 … IHB … HB) #HV0
143   @(s4 … IHA … (V0 @ V0s)) /3 width=7 by rp_liftsv_all, conj/
144 | #I #G #L #K #Vs #V1 #V2 #i #HA #HV12 #HLK #L0 #V0 #X #des #HL0 #H #HB
145   elim (lifts_inv_applv1 … H) -H #V0s #Y #HV0s #HY #H destruct
146   elim (lifts_inv_lref1 … HY) -HY #i0 #Hi0 #H destruct
147   elim (drops_drop_trans … HL0 … HLK) #X #des0 #i1 #HL02 #H #Hi1 #Hdes0
148   >(at_mono … Hi1 … Hi0) in HL02; -i1 #HL02
149   elim (drops_inv_skip2 … Hdes0 … H) -H -des0 #L2 #W1 #des0 #Hdes0 #HLK #HVW1 #H destruct
150   elim (lift_total W1 0 (i0 + 1)) #W2 #HW12
151   elim (lifts_lift_trans  … Hdes0 … HVW1 … HW12) // -Hdes0 -Hi0 #V3 #HV13 #HVW2
152   >(lift_mono … HV13 … HV12) in HVW2; -V3 #HVW2
153   @(s5 … IHA … (V0 @ V0s) … HW12 HL02) /3 width=5 by lifts_applv/
154 | #G #L #V1s #V2s #HV12s #a #V #T #HA #HV #L0 #V10 #X #des #HL0 #H #HB
155   elim (lifts_inv_applv1 … H) -H #V10s #Y #HV10s #HY #H destruct
156   elim (lifts_inv_bind1 … HY) -HY #V0 #T0 #HV0 #HT0 #H destruct
157   elim (lift_total V10 0 1) #V20 #HV120
158   elim (liftv_total 0 1 V10s) #V20s #HV120s
159   @(s6 … IHA … (V10 @ V10s) (V20 @ V20s)) /3 width=7 by rp_lifts, liftv_cons/
160   @(HA … (des + 1)) /2 width=2 by drops_skip/
161   [ @lifts_applv //
162     elim (liftsv_liftv_trans_le … HV10s … HV120s) -V10s #V10s #HV10s #HV120s
163     >(liftv_mono … HV12s … HV10s) -V1s //
164   | @(s0 … IHB … HB … HV120) /2 width=2 by drop_drop/
165   ]
166 | #G #L #Vs #T #W #HA #HW #L0 #V0 #X #des #HL0 #H #HB
167   elim (lifts_inv_applv1 … H) -H #V0s #Y #HV0s #HY #H destruct
168   elim (lifts_inv_flat1 … HY) -HY #W0 #T0 #HW0 #HT0 #H destruct
169   @(s7 … IHA … (V0 @ V0s)) /3 width=5 by lifts_applv/
170 ]
171 qed.
172
173 lemma acr_abst: ∀RR,RS,RP. gcp RR RS RP → gcr RR RS RP RP →
174                 ∀a,G,L,W,T,A,B. ⦃G, L, W⦄ ϵ[RP] 〚B〛 → (
175                    ∀L0,V0,W0,T0,des. ⇩*[Ⓕ, des] L0 ≡ L → ⇧*[des] W ≡ W0 → ⇧*[des + 1] T ≡ T0 →
176                                    ⦃G, L0, V0⦄ ϵ[RP] 〚B〛 → ⦃G, L0, W0⦄ ϵ[RP] 〚B〛 → ⦃G, L0.ⓓⓝW0.V0, T0⦄ ϵ[RP] 〚A〛
177                 ) →
178                 ⦃G, L, ⓛ{a}W.T⦄ ϵ[RP] 〚②B.A〛.
179 #RR #RS #RP #H1RP #H2RP #a #G #L #W #T #A #B #HW #HA #L0 #V0 #X #des #HL0 #H #HB
180 lapply (acr_gcr … H1RP H2RP A) #HCA
181 lapply (acr_gcr … H1RP H2RP B) #HCB
182 elim (lifts_inv_bind1 … H) -H #W0 #T0 #HW0 #HT0 #H destruct
183 lapply (gcr_lifts … HL0 … HW0 HW) -HW [ @(s0 … HCB) ] #HW0
184 @(s3 … HCA … (◊))
185 @(s6 … HCA … (◊) (◊)) //
186 [ @(HA … HL0) //
187 | lapply (s1 … HCB) -HCB #HCB
188   @(s7 … H2RP … (◊)) /2 width=1 by/
189 ]
190 qed.
191
192 (* Basic_1: removed theorems 2: sc3_arity_gen sc3_repl *)
193 (* Basic_1: removed local theorems 1: sc3_sn3_abst *)