]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambda_delta/Basic_2/computation/acp_cr.ma
9f94d8969092f22419e62df7916a5e15fb378423
[helm.git] / matita / matita / contribs / lambda_delta / Basic_2 / computation / acp_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/grammar/aarity.ma".
16 include "Basic_2/unfold/gr2_gr2.ma".
17 include "Basic_2/unfold/lifts_lift_vector.ma".
18 include "Basic_2/unfold/ldrops_ldrop.ma".
19 include "Basic_2/computation/acp.ma".
20
21 (* ABSTRACT COMPUTATION PROPERTIES ******************************************)
22
23 (* Note: this is Girard's CR1 *)
24 definition S1 ≝ λRP,C:lenv→predicate term.
25                 ∀L,T. C L T → RP L T.
26
27 (* Note: this is Tait's iii, or Girard's CR4 *)
28 definition S2 ≝ λRR:lenv→relation term. λRS:relation term. λRP,C:lenv→predicate term.
29                 ∀L,Vs. all … (RP L) Vs →
30                 ∀T. 𝕊[T] → NF … (RR L) RS T → C L (ⒶVs.T).
31
32 (* Note: this is Tait's ii *)
33 definition S3 ≝ λRP,C:lenv→predicate term.
34                 ∀L,Vs,V,T,W. C L (ⒶVs. ⓓV. T) → RP L W → C L (ⒶVs. ⓐV. ⓛW. T).
35
36 definition S4 ≝ λRP,C:lenv→predicate term. ∀L,K,Vs,V1,V2,i.
37                 C L (ⒶVs. V2) → ⇧[0, i + 1] V1 ≡ V2 →
38                 ⇩[0, i] L ≡ K. ⓓV1 → C L (Ⓐ Vs. #i).
39
40 definition S5 ≝ λRP,C:lenv→predicate term.
41                 ∀L,V1s,V2s. ⇧[0, 1] V1s ≡ V2s →
42                 ∀V,T. C (L. ⓓV) (ⒶV2s. T) → RP L V → C L (ⒶV1s. ⓓV. T).
43
44 definition S6 ≝ λRP,C:lenv→predicate term.
45                 ∀L,Vs,T,W. C L (ⒶVs. T) → RP L W → C L (ⒶVs. ⓣW. T).
46
47 definition S7 ≝ λC:lenv→predicate term. ∀L1,L2,T1,T2,d,e.
48                 C L1 T1 → ⇩[d, e] L2 ≡ L1 → ⇧[d, e] T1 ≡ T2 → C L2 T2.
49
50 definition S7s ≝ λC:lenv→predicate term.
51                  ∀L1,L2,des. ⇩*[des] L2 ≡ L1 →
52                  ∀T1,T2. ⇧*[des] T1 ≡ T2 → C L1 T1 → C L2 T2.
53
54 (* properties of the abstract candidate of reducibility *)
55 record acr (RR:lenv->relation term) (RS:relation term) (RP,C:lenv→predicate term) : Prop ≝
56 { s1: S1 RP C;
57   s2: S2 RR RS RP C;
58   s3: S3 RP C;
59   s4: S4 RP C;
60   s5: S5 RP C;
61   s6: S6 RP C;
62   s7: S7 C
63 }.
64
65 (* the abstract candidate of reducibility associated to an atomic arity *)
66 let rec aacr (RP:lenv→predicate term) (A:aarity) (L:lenv) on A: predicate term ≝
67 λT. match A with
68 [ AAtom     ⇒ RP L T
69 | APair B A ⇒ ∀L0,V0,T0,des. aacr RP B L0 V0 → ⇩*[des] L0 ≡ L → ⇧*[des] T ≡ T0 →
70               aacr RP A L0 (ⓐV0. T0)
71 ].
72
73 interpretation
74    "candidate of reducibility of an atomic arity (abstract)"
75    'InEInt RP L T A = (aacr RP A L T).
76
77 (* Basic properties *********************************************************)
78
79 lemma acr_lifts: ∀C. S7 C → S7s C.
80 #C #HC #L1 #L2 #des #H elim H -L1 -L2 -des
81 [ #L #T1 #T2 #H #HT1
82   <(lifts_inv_nil … H) -H //
83 | #L1 #L #L2 #des #d #e #_ #HL2 #IHL #T2 #T1 #H #HLT2
84   elim (lifts_inv_cons … H) -H /3 width=9/
85 ]
86 qed.
87
88 lemma rp_lifts: ∀RR,RS,RP. acr RR RS RP (λL,T. RP L T) →
89                 ∀des,L0,L,V,V0. ⇩*[des] L0 ≡ L → ⇧*[des] V ≡ V0 →
90                 RP L V → RP L0 V0.
91 #RR #RS #RP #HRP #des #L0 #L #V #V0 #HL0 #HV0 #HV 
92 @acr_lifts /width=6/
93 @(s7 … HRP)
94 qed.
95
96 lemma rp_liftsv_all: ∀RR,RS,RP. acr RR RS RP (λL,T. RP L T) →
97                      ∀des,L0,L,Vs,V0s. ⇧*[des] Vs ≡ V0s →  ⇩*[des] L0 ≡ L →
98                      all … (RP L) Vs → all … (RP L0) V0s.
99 #RR #RS #RP #HRP #des #L0 #L #Vs #V0s #H elim H -Vs -V0s normalize //
100 #T1s #T2s #T1 #T2 #HT12 #_ #IHT2s #HL0 * #HT1 #HT1s
101 @conj /2 width=1/ /2 width=6 by rp_lifts/
102 qed.
103
104 lemma aacr_acr: ∀RR,RS,RP. acp RR RS RP → acr RR RS RP (λL,T. RP L T) →
105                 ∀A. acr RR RS RP (aacr RP A).
106 #RR #RS #RP #H1RP #H2RP #A elim A -A normalize //
107 #B #A #IHB #IHA @mk_acr normalize
108 [ #L #T #H
109   lapply (H ? (⋆0) ? ⟠ ? ? ?) -H
110   [1,3: // |2,4: skip
111   | @(s2 … IHB … ◊) // /2 width=2/
112   | #H @(cp3 … H1RP … 0) @(s1 … IHA) //
113   ]
114 | #L #Vs #HVs #T #H1T #H2T #L0 #V0 #X #des #HB #HL0 #H
115   elim (lifts_inv_applv1 … H) -H #V0s #T0 #HV0s #HT0 #H destruct
116   lapply (s1 … IHB … HB) #HV0
117   @(s2 … IHA … (V0 :: V0s)) /2 width=4 by lifts_simple_dx/ /3 width=6/
118 | #L #Vs #U #T #W #HA #HW #L0 #V0 #X #des #HB #HL0 #H
119   elim (lifts_inv_applv1 … H) -H #V0s #Y #HV0s #HY #H destruct
120   elim (lifts_inv_flat1 … HY) -HY #U0 #X #HU0 #HX #H destruct
121   elim (lifts_inv_bind1 … HX) -HX #W0 #T0 #HW0 #HT0 #H destruct
122   @(s3 … IHA … (V0 :: V0s)) /2 width=6 by rp_lifts/ /4 width=5/
123 | #L #K #Vs #V1 #V2 #i #HA #HV12 #HLK #L0 #V0 #X #des #HB #HL0 #H
124   elim (lifts_inv_applv1 … H) -H #V0s #Y #HV0s #HY #H destruct
125   elim (lifts_inv_lref1 … HY) -HY #i0 #Hi0 #H destruct
126   elim (ldrops_ldrop_trans … HL0 … HLK) #X #des0 #i1 #HL02 #H #Hi1 #Hdes0
127   >(at_mono … Hi1 … Hi0) in HL02; -i1 #HL02
128   elim (ldrops_inv_skip2 … Hdes0 … H) -H -des0 #L2 #W1 #des0 #Hdes0 #HLK #HVW1 #H destruct
129   elim (lift_total W1 0 (i0 + 1)) #W2 #HW12
130   elim (lifts_lift_trans … HVW1 … HW12 … Hdes0) // -Hdes0 -Hi0 #V3 #HV13 #HVW2
131   >(lift_mono … HV13 … HV12) in HVW2; -V3 #HVW2
132   @(s4 … IHA … (V0 :: V0s) … HW12 HL02) /3 width=4/
133 | #L #V1s #V2s #HV12s #V #T #HA #HV #L0 #V10 #X #des #HB #HL0 #H
134   elim (lifts_inv_applv1 … H) -H #V10s #Y #HV10s #HY #H destruct
135   elim (lifts_inv_bind1 … HY) -HY #V0 #T0 #HV0 #HT0 #H destruct
136   elim (lift_total V10 0 1) #V20 #HV120
137   elim (liftv_total 0 1 V10s) #V20s #HV120s
138   @(s5 … IHA … (V10 :: V10s) (V20 :: V20s)) /2 width=1/ /2 width=6 by rp_lifts/
139   @(HA … (des + 1)) /2 width=1/
140   [ @(s7 … IHB … HB … HV120) /2 width=1/
141   | @lifts_applv //
142     elim (liftsv_liftv_trans_le … HV10s … HV120s) -V10s #V10s #HV10s #HV120s
143     >(liftv_mono … HV12s … HV10s) -V1s //
144   ]
145 | #L #Vs #T #W #HA #HW #L0 #V0 #X #des #HB #HL0 #H
146   elim (lifts_inv_applv1 … H) -H #V0s #Y #HV0s #HY #H destruct
147   elim (lifts_inv_flat1 … HY) -HY #W0 #T0 #HW0 #HT0 #H destruct
148   @(s6 … IHA … (V0 :: V0s)) /2 width=6 by rp_lifts/ /3 width=4/
149 | /3 width=7/
150 ]
151 qed.
152
153 lemma aacr_abst: ∀RR,RS,RP. acp RR RS RP → acr RR RS RP (λL,T. RP L T) →
154                  ∀L,W,T,A,B. RP L W → (
155                     ∀L0,V0,T0,des. ⇩*[des] L0 ≡ L → ⇧*[des + 1] T ≡ T0 →
156                                    ⦃L0, V0⦄ [RP] ϵ 〚B〛 → ⦃L0. ⓓV0, T0⦄ [RP] ϵ 〚A〛
157                  ) →
158                  ⦃L, ⓛW. T⦄ [RP] ϵ 〚②B. A〛.
159 #RR #RS #RP #H1RP #H2RP #L #W #T #A #B #HW #HA #L0 #V0 #X #des #HB #HL0 #H
160 lapply (aacr_acr … H1RP H2RP A) #HCA
161 lapply (aacr_acr … H1RP H2RP B) #HCB
162 elim (lifts_inv_bind1 … H) -H #W0 #T0 #HW0 #HT0 #H destruct
163 lapply (s1 … HCB) -HCB #HCB
164 @(s3 … HCA … ◊) /2 width=6 by rp_lifts/
165 @(s5 … HCA … ◊ ◊) // /2 width=1/ /2 width=3/
166 qed.