]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/basic_2/dynamic/cnv_eval.ma
update in ground_2 static_2 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_equivalence/cpes_cpes.ma".
16 include "basic_2/dynamic/cnv_cpmhe.ma".
17 include "basic_2/dynamic/cnv_cpes.ma".
18 include "basic_2/dynamic/cnv_preserve_cpes.ma".
19
20 (* CONTEXT-SENSITIVE NATIVE VALIDITY FOR TERMS ******************************)
21
22 (* main properties with evaluations for rt-transition on terms **************)
23
24 theorem cnv_dec (a) (h) (G) (L) (T): ac_props a →
25         Decidable (⦃G,L⦄ ⊢ T ![a,h]).
26 #a #h #G #L #T #Ha
27 @(fqup_wf_ind_eq (Ⓣ) … G L T) -G -L -T #G0 #L0 #T0 #IH #G #L * * [|||| * ]
28 [ #s #HG #HL #HT destruct -Ha -IH
29   /2 width=1 by cnv_sort, or_introl/
30 | #i #HG #HL #HT destruct -Ha
31   elim (drops_F_uni L i) [| * * ]
32   [ /3 width=8 by cnv_inv_lref_atom, or_intror/
33   | /3 width=9 by cnv_inv_lref_unit, or_intror/
34   | #I #V #K #HLK
35     elim (IH G K V) -IH [3: /2 width=2 by fqup_lref/ ]
36     [ /3 width=5 by cnv_lref_drops, or_introl/
37     | /4 width=5 by cnv_inv_lref_pair, or_intror/
38     ]
39   ]
40 | #l #HG #HL #HT destruct -Ha -IH
41   /3 width=6 by cnv_inv_gref, or_intror/
42 | #p #I #V #T #HG #HL #HT destruct -Ha
43   elim (IH G L V) [| -IH | // ] #HV
44   [ elim (IH G (L.ⓑ{I}V) T) -IH [3: // ] #HT
45     [ /3 width=1 by cnv_bind, or_introl/ ]
46   ]
47   @or_intror #H
48   elim (cnv_inv_bind … H) -H /2 width=1 by/
49 | #V #T #HG #HL #HT destruct
50   elim (IH G L V) [| -IH #HV | // ]
51   [ elim (IH G L T) -IH [| #HT #HV | // ]
52     [ #HT #HV
53       elim (cnv_R_cpmhe_total … HT) #n #Hn
54       elim (dec_min (R_cpmhe h G L T) … Hn) -Hn
55       [| /2 width=2 by cnv_R_cpmhe_dec/ ] #n0 #_ -n
56       elim (ac_dec … Ha n0) -Ha
57       [ * #n #Hn #Ha * #X0 #HX0 #_
58         elim (abst_dec X0)
59         [ * #p #W #U0 #H destruct
60           elim (cnv_cpes_dec … 1 0 … HV W) [ #HVW | #HnVW ]
61           [ lapply (cpmhe_fwd_cpms … HX0) -HX0 #HTU0
62             elim (cnv_fwd_cpms_abst_dx_le … HT … HTU0 … Hn) #U #HTU #_ -U0 -n0
63             /3 width=7 by cnv_appl_cpes, or_introl/
64 (* Note: argument type mismatch *)
65           | @or_intror #H -n
66             elim (cnv_inv_appl_cpes … H) -H #m0 #q #WX #UX #_ #_ #_ #HVWX #HTUX
67             lapply (cpmhe_abst … HTUX) -HTUX #HTUX
68             elim (cnv_cpmhe_mono … HT … HTUX … HX0) -a -T #H #_
69             elim (cpes_fwd_abst_bi … H) -H #_ #HWX -n0 -m0 -p -q -UX -U0
70             /3 width=3 by cpes_cpes_trans/
71           | lapply (cnv_cpmhe_trans … HT … HX0) -T #H
72             elim (cnv_inv_bind … H) -H #HW #_ //
73           ]
74 (* Note: no expected type *)
75         | #HnX0
76           @or_intror #H
77           elim (cnv_inv_appl_cpes … H) -H #m0 #q #W0 #U0 #_ #_ #_ #_ #HTU0
78           lapply (cpmhe_abst … HTU0) -HTU0 #HTU0
79           elim (cnv_cpmhe_mono … HT … HTU0 … HX0) -T #_ #H
80           elim (theq_inv_pair1 … H) -W0 -U0 #W0 #U0 #H destruct
81           /2 width=4 by/
82         ]
83 (* Note: failed applicability *)
84       | #Hge #_ #Hlt
85         @or_intror #H
86         elim (cnv_inv_appl … H) -H #m0 #q #W0 #U0 #Hm0 #_ #_ #_ #HTU0
87         elim (lt_or_ge m0 n0) #H0 [| /3 width=3 by ex2_intro/ ] -Hm0 -Hge
88         /4 width=6 by cpmhe_abst, ex_intro/
89       ]
90     ]
91   ]
92   @or_intror #H
93   elim (cnv_inv_appl … H) -H /2 width=1 by/
94 | #U #T #HG #HL #HT destruct
95   elim (IH G L U) [| -IH | // ] #HU
96   [ elim (IH G L T) -IH [3: // ] #HT
97     [ elim (cnv_cpes_dec … 0 1 … HU … HT) #HUT
98       [ /3 width=1 by cnv_cast_cpes, or_introl/ ]
99     ]
100   ]
101   @or_intror #H
102   elim (cnv_inv_cast_cpes … H) -H /2 width=1 by/
103 ]
104 qed-.