]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambda_delta/Basic_2/reducibility/tnf.ma
a9a262efed9b6ef5a23066e547d1b71377b70dd7
[helm.git] / matita / matita / contribs / lambda_delta / Basic_2 / reducibility / tnf.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/substitution/tps_lift.ma".
16 include "Basic_2/reducibility/trf.ma".
17 include "Basic_2/reducibility/tpr.ma".
18
19 (* CONTEXT-FREE NORMAL TERMS ************************************************)
20
21 definition tnf: term → Prop ≝
22    NF … tpr (eq …).
23
24 interpretation
25    "context-free normality (term)"
26    'Normal T = (tnf T).
27
28 (* Basic inversion lemmas ***************************************************)
29
30 lemma tnf_inv_abst: ∀V,T. ℕ[𝕔{Abst}V.T] → ℕ[V] ∧ ℕ[T].
31 #V1 #T1 #HVT1 @conj
32 [ #V2 #HV2 lapply (HVT1 (𝕔{Abst}V2.T1) ?) -HVT1 /2/ -HV2 #H destruct -V1 T1 //
33 | #T2 #HT2 lapply (HVT1 (𝕔{Abst}V1.T2) ?) -HVT1 /2/ -HT2 #H destruct -V1 T1 //
34 ]
35 qed-.
36
37 lemma tnf_inv_appl: ∀V,T. ℕ[𝕔{Appl}V.T] → ∧∧ ℕ[V] & ℕ[T] & 𝕊[T].
38 #V1 #T1 #HVT1 @and3_intro
39 [ #V2 #HV2 lapply (HVT1 (𝕔{Appl}V2.T1) ?) -HVT1 /2/ -HV2 #H destruct -V1 T1 //
40 | #T2 #HT2 lapply (HVT1 (𝕔{Appl}V1.T2) ?) -HVT1 /2/ -HT2 #H destruct -V1 T1 //
41 | generalize in match HVT1 -HVT1; elim T1 -T1 * // * #W1 #U1 #_ #_ #H
42   [ elim (lift_total V1 0 1) #V2 #HV12
43     lapply (H (𝕔{Abbr}W1.𝕔{Appl}V2.U1) ?) -H /2/ -HV12 #H destruct
44   | lapply (H (𝕔{Abbr}V1.U1) ?) -H /2/ #H destruct
45 ]
46 qed-.
47
48 lemma tnf_inv_abbr: ∀V,T. ℕ[𝕔{Abbr}V.T] → False.
49 #V #T #H elim (is_lift_dec T 0 1)
50 [ * #U #HTU
51   lapply (H U ?) -H /2 width=3/ #H destruct -U;
52   elim (lift_inv_pair_xy_y … HTU)
53 | #HT
54   elim (tps_full (⋆) V T (⋆. 𝕓{Abbr} V) 0 ?) // #T2 #T1 #HT2 #HT12
55   lapply (H (𝕓{Abbr}V.T2) ?) -H /2/ -HT2 #H destruct -T /3 width=2/
56 ]
57 qed.
58
59 lemma tnf_inv_cast: ∀V,T. ℕ[𝕔{Cast}V.T] → False.
60 #V #T #H lapply (H T ?) -H /2 width=1/ #H
61 @(discr_tpair_xy_y … H)
62 qed-.
63
64 (* Basic properties *********************************************************)
65
66 lemma tpr_tif_eq: ∀T1,T2. T1 ⇒ T2 →  𝕀[T1] → T1 = T2.
67 #T1 #T2 #H elim H -T1 T2
68 [ //
69 | * #V1 #V2 #T1 #T2 #_ #_ #IHV1 #IHT1 #H
70   [ elim (tif_inv_appl … H) -H #HV1 #HT1 #_
71     >IHV1 -IHV1 // -HV1 >IHT1 -IHT1 //
72   | elim (tif_inv_cast … H)
73   ]
74 | #V1 #V2 #W #T1 #T2 #_ #_ #_ #_ #H
75   elim (tif_inv_appl … H) -H #_ #_ #H
76   elim (simple_inv_bind … H)
77 | * #V1 #V2 #T1 #T #T2 #_ #_ #HT2 #IHV1 #IHT1 #H
78   [ -HT2 IHV1 IHT1; elim (tif_inv_abbr … H)
79   | <(tps_inv_refl_SO2 … HT2 ?) -HT2 //
80     elim (tif_inv_abst … H) -H #HV1 #HT1
81     >IHV1 -IHV1 // -HV1 >IHT1 -IHT1 //
82   ]
83 | #V #V1 #V2 #W1 #W2 #T1 #T2 #_ #_ #_ #_ #_ #_ #_ #H
84   elim (tif_inv_appl … H) -H #_ #_ #H
85   elim (simple_inv_bind … H)
86 | #V1 #T1 #T2 #T #_ #_ #_ #H
87   elim (tif_inv_abbr … H)
88 | #V1 #T1 #T #_ #_ #H
89   elim (tif_inv_cast … H)
90 ]
91 qed.
92
93 theorem tif_tnf: ∀T1.  𝕀[T1] → ℕ[T1].
94 /2/ qed.
95
96 (* Note: this property is unusual *)
97 theorem tnf_trf_false: ∀T1. ℝ[T1] → ℕ[T1] → False.
98 #T1 #H elim H -T1
99 [ #V #T #_ #IHV #H elim (tnf_inv_abst … H) -H /2/
100 | #V #T #_ #IHT #H elim (tnf_inv_abst … H) -H /2/
101 | #V #T #_ #IHV #H elim (tnf_inv_appl … H) -H /2/
102 | #V #T #_ #IHV #H elim (tnf_inv_appl … H) -H /2/
103 | #V #T #H elim (tnf_inv_abbr … H)
104 | #V #T #H elim (tnf_inv_cast … H)
105 | #V #W #T #H elim (tnf_inv_appl … H) -H #_ #_ #H
106   elim (simple_inv_bind … H)
107 ]
108 qed.
109
110 theorem tnf_tif: ∀T1. ℕ[T1] → 𝕀[T1].
111 /2/ qed.
112
113 lemma tnf_abst: ∀V,T. ℕ[V] → ℕ[T] → ℕ[𝕔{Abst}V.T].
114 /4 width=1/ qed.
115
116 lemma tnf_appl: ∀V,T. ℕ[V] → ℕ[T] → 𝕊[T] → ℕ[𝕔{Appl}V.T].
117 /4 width=1/ qed.