]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/basic_2/dynamic/cnv_eval.ma
0052d7cb47b46644efe8497f9127f1407d9b4237
[helm.git] / matita / matita / contribs / lambdadelta / basic_2 / dynamic / cnv_eval.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/rt_computation/cpue_csx.ma".
16 include "basic_2/rt_equivalence/cpes_cprs.ma".
17 include "basic_2/dynamic/cnv_cpue.ma".
18 include "basic_2/dynamic/cnv_cpes.ma".
19 include "basic_2/dynamic/cnv_preserve_cpes.ma".
20
21 (* CONTEXT-SENSITIVE NATIVE VALIDITY FOR TERMS ******************************)
22
23 lemma abst_dec (X): ∨∨ ∃∃p,W,T. X = ⓛ{p}W.T
24                      | (∀p,W,T. X = ⓛ{p}W.T → ⊥).
25 * [ #I | * [ #p * | #I ] #V #T ]
26 [3: /3 width=4 by ex1_3_intro, or_introl/ ]
27 @or_intror #q #W #U #H destruct
28 qed-.
29
30 (* main properties with evaluations for rt-transition on terms **************)
31
32 theorem cnv_dec (a) (h) (G) (L) (T):
33         Decidable (⦃G,L⦄ ⊢ T ![a,h]).
34 #a #h #G #L #T
35 @(fqup_wf_ind_eq (Ⓣ) … G L T) -G -L -T #G0 #L0 #T0 #IH #G #L * * [|||| * ]
36 [ #s #HG #HL #HT destruct -IH
37   /2 width=1 by cnv_sort, or_introl/
38 | #i #HG #HL #HT destruct
39   elim (drops_F_uni L i) [| * * ]
40   [ /3 width=8 by cnv_inv_lref_atom, or_intror/
41   | /3 width=9 by cnv_inv_lref_unit, or_intror/
42   | #I #V #K #HLK
43     elim (IH G K V) -IH [3: /2 width=2 by fqup_lref/ ]
44     [ /3 width=5 by cnv_lref_drops, or_introl/
45     | /4 width=5 by cnv_inv_lref_pair, or_intror/
46     ]
47   ]
48 | #l #HG #HL #HT destruct -IH
49   /3 width=6 by cnv_inv_gref, or_intror/
50 | #p #I #V #T #HG #HL #HT destruct
51   elim (IH G L V) [| -IH | // ] #HV
52   [ elim (IH G (L.ⓑ{I}V) T) -IH [3: // ] #HT
53     [ /3 width=1 by cnv_bind, or_introl/ ]
54   ]
55   @or_intror #H
56   elim (cnv_inv_bind … H) -H /2 width=1 by/
57 | #V #T #HG #HL #HT destruct
58   elim (IH G L V) [| -IH #HV | // ]
59   [ elim (IH G L T) -IH [| #HT #HV | // ]
60     [ cases a #HT #HV
61       [ elim (cnv_fwd_aaa … HT) #A #HA
62         elim (cpme_total_aaa h 1 … HA) #X
63         elim (abst_dec X) [ * ]
64         [ #p #W #U #H #HTU destruct
65           elim (cnv_cpes_dec … 1 0 … HV W) [ #HVW | #HnVW ]
66           [ elim HTU -HTU #HTU #_
67             /3 width=7 by cnv_appl_cpes, or_introl/
68           | @or_intror #H
69             elim (cnv_inv_appl_SO_cpes … H) -H #m1 #q #W0 #U0 #Hm1 #_ #_ #HVW0
70             >Hm1 -m1 [| // ] #HTU0
71             elim (cnv_cpme_cpms_conf … HT … HTU0 … HTU) -T #HU0 #_
72             elim (cpms_inv_abst_bi … HU0) -HU0 #_ #HW0 #_ -p -q -U0
73             /3 width=3 by cpes_cprs_trans/
74           | lapply (cnv_cpme_trans … HT … HTU) -T #H
75             elim (cnv_inv_bind … H) -H #HW #_ //
76           ]
77         | #HnTU #HTX
78           @or_intror #H
79           elim (cnv_inv_appl_SO_cpes … H) -H #m1 #q #W0 #U0 #Hm1 #_ #_ #_
80           >Hm1 -m1 [| // ] #HTU0
81           elim (cnv_cpme_cpms_conf … HT … HTU0 … HTX) -T #HX #_
82           elim (cpms_inv_abst_sn … HX) -HX #V0 #T0 #_ #_ #H destruct -W0 -U0
83           /2 width=4 by/
84         ]
85       | elim (cpue_total_csx h G L T)
86         [| /3 width=2 by cnv_fwd_fsb, fsb_inv_csx/ ] #X
87         elim (abst_dec X) [ * ]
88         [ #p #W #U #H #HTU destruct
89           elim (cnv_cpes_dec … 1 0 … HV W) [ #HVW | #HnVW ]
90           [ elim HTU -HTU #n #HTU #_
91             @or_introl @(cnv_appl_cpes … HV … HT … HVW … HTU) #H destruct
92           | @or_intror #H
93             elim (cnv_inv_appl_SO_cpes … H) -H #m1 #q #W0 #U0 #_ #_ #_ #HVW0 #HTU0
94             elim (cnv_cpue_cpms_conf … HT … HTU0 … HTU) -m1 -T #X * #m2 #HU0X #_ #HUX
95             elim (tueq_inv_bind1 … HUX) -HUX #X0 #_ #H destruct -U
96             elim (cpms_inv_abst_bi … HU0X) -HU0X #_ #HW0 #_ -p -q -m2 -U0 -X0
97             /3 width=3 by cpes_cprs_trans/
98           | lapply (cnv_cpue_trans … HT … HTU) -T #H
99             elim (cnv_inv_bind … H) -H #HW #_ //
100           ]
101         | #HnTU #HTX
102           @or_intror #H
103           elim (cnv_inv_appl_SO_cpes … H) -H #m1 #q #W0 #U0 #_ #_ #_ #_ #HTU0
104           elim (cnv_cpue_cpms_conf … HT … HTU0 … HTX) -m1 -T #X0 * #m2 #HUX0 #_ #HX0
105           elim (cpms_inv_abst_sn … HUX0) -HUX0 #V0 #T0 #_ #_ #H destruct -m2 -W0 -U0
106           elim (tueq_inv_bind2 … HX0) -HX0 #X0 #_ #H destruct
107           /2 width=4 by/
108         ]
109       ]
110     ]
111   ]
112   @or_intror #H
113   elim (cnv_inv_appl_SO … H) -H /2 width=1 by/
114 | #U #T #HG #HL #HT destruct
115   elim (IH G L U) [| -IH | // ] #HU
116   [ elim (IH G L T) -IH [3: // ] #HT
117     [ elim (cnv_cpes_dec … 0 1 … HU … HT) #HUT
118       [ /3 width=1 by cnv_cast_cpes, or_introl/ ]
119     ]
120   ]
121   @or_intror #H
122   elim (cnv_inv_cast_cpes … H) -H /2 width=1 by/
123 ]
124 qed-.