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